Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT instead of text boxe i have to show check box as selected.

Have Programming Question? Ask it here!
 
 
 


raveen
instead of text boxe i have to show check box as selected.
1 Answer(s)      2 years and 3 months ago
Posted in : Swing AWT


i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i have to show check box as selected.

Thanks In advance R.Raveen.


Advertisement
View Answers

May 17, 2012 at 3:46 PM


The given code retrieves the data from the database table and show values on Frame.

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class ShowCheckboxSelected extends JFrame
{

ShowCheckboxSelected(){
String des = "Deselected";
String sel = "Selected";

JLabel label1 = new JLabel();
label1.setText("Name:");
JTextField text1 = new JTextField(20);

JLabel label2 = new JLabel();
label2.setText("Age:");
JTextField text2 = new JTextField(20);

JLabel label3 = new JLabel("Indian?");
JCheckBox check = new JCheckBox();


JPanel panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(check);
add(panel);

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from employee where id='2'");
        String str=" ";
        if(rs.next()){
            text1.setText(rs.getString("name"));
            text2.setText(Integer.toString(rs.getInt("Age")));
            str=rs.getString("nationality");
            System.out.println(str);
            if(str.equals("true")){
                check.setSelected(true);
            }
            else{
                check.setSelected(false);
            }

        }
    }
catch(Exception e){}

}
public static void main(String arg[]){
try
{
ShowCheckboxSelected frame=new ShowCheckboxSelected();
frame.pack();
frame.setVisible(true);
}
catch(Exception e)
{}
}
}


Related Tutorials/Questions & Answers:
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have... the database. when ever the valsue is there in textfield, instead of text boxe i have to show check box as selected. Thanks In advance R.Raveen.
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
Dynamically display values in dropdown box and then show the selected values... this code it is adding one more value to the dropdown box and showing as selected. so if I have 5 values in the dropdown this selected one is added as 6th values
Advertisements
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
in the list box. Somehow I can just show only one as selected but not multiple records...Dynamically display values in dropdown box and then show the selected values..., This is for Updating. I had two SQL queries one for only selected values
check box in jsp
check box in jsp  hey guys i am working on a web based project using jsp. In my project 1 am having 9 check boxes in 3 rows in the same form. I want to select 1 check box from each row and also i want to avoid many check box
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
Show text field & check input using jQuery
Show text field & check input using jQuery In this tutorial, we will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using
textfield selected text
textfield selected text  How to select text in text field
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile... the result is ok but after getting value of first box now i want a result of second box
Dynamic check box problem
Dynamic check box problem  In my project i have used a dynamic table, in the each row of that table there is one check box [that i have created...='enable_text()' name="check"> <td><input type="text" name="name
two text box problem
two text box problem  i have two text box in two different pages and same variable use in two text box when enter value in first text box it's reflection show in second text box , how i reduce it in jsf ?   Hi Friend
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below... code for me jsp file... <%@page contentType="text/html" pageEncoding...;<input type="text" value =" " property= "amount" id='pricecheck'/>
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below... code for me jsp file... <%@page contentType="text/html" pageEncoding...;<input type="text" value =" " property= "amount" id='pricecheck'/> <
how to insert check box
how to insert check box   how to insert check box into jtable row in swing
check box left justification
check box left justification  how to make a check box left justification which is at right end? thanks in advance
I am getting Undefined in Text Box Very Urgent - JSP-Servlet
I am getting Undefined in Text Box Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I got the coding. But I find... the value "Undefined" in Emp ID text box which is present in the main page.. Here's
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
HI Jsp check box..!
HI Jsp check box..!  Hi all.. I want to update the multiple values of database table using checkbox..after clicking submit the edited field has to update and rest has to enable to update...please help me..its urgent
show selected date range in calender
show selected date range in calender  helo, i'm working in a project in jsp. suppose thier are 2 textbox 1.start date 2. end date whatever date selected in these textbox get highlighted in the calendar, please help
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.  I have a tex box. in that i want user should enter data in the format specified(for eg--abcde_)how
check box condition
check box condition  Hai, my application has two check box one for chart and another one for table.when We click chart check box download only chart but table also download.same problem in table slection..xsl coding was used
Text box Checking
Text box Checking  I want to Write only the word A-Z in a text box What is the code
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface... is your code, we have modified it. import java.io.*; interface arith { int a=5
Check Box Validation in PHP - PHP
Check Box Validation in PHP  How can validations done on check boxes more than 3?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/javascript-array/javascript-array-checkboxes.shtml
java script text box
in alert). i also want the text box should generate in front of NEW button(next/prev...java script text box  hi, I created a button when i click on button(next/prev) new two textbox is created. i want to do the two textbox will show
check box realtive information in page store in database
check box realtive information in page store in database  check box relative information in page store in database  hiiiiiiiii, Que I create a checkbox in html and when i click on my check box realtive information
Text box control--keypress event
Text box control--keypress event  In my form have a text box...My requirement is... when is type characters in that box... before typing the 3rd character the space should come automatically or programmatically...the sturucture
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am designing a bill calculate program. I want to print the bill in crystal form. I want to skip all the text fields shapes and all the button from the frame.. but all
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
enable text box
enable text box  Dear all I would like to enable a textbox by clicking on a button. pleas ehelp me out how can i do this regards JV
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
Drag a Text Box into dynamic positions
Drag a Text Box into dynamic positions  Plz can anyone tell how can i drag a text box using mouse or arrow keys... Im doing a accounts projects and i need this feature for cheque configuration
How to check text in textbox using JavaScript
How to check text in textbox using JavaScript  How to check text in textbox using JavaScript I have a form in HTML that contains text feilds... qestion is that is it possible to check text feilds for text or null value. I want
To display suggestions in a text box - Ajax
To display suggestions in a text box  Hi All, I have a requirement, to get the suggestions i mean when i enter the alphabet in a text box(For ex:'A'), the names that starts from 'A' have to display in the text box
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
Creating Check Box in Java Swing
Creating Check Box in Java Swing       This section illustrates you how to create a Check Box component in Java Swing. In this section, you can learn simply creating the Check Box
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
How to assign a default value to text box in netbeans
How to assign a default value to text box in netbeans  I have a java application,and i want to assign a default variable to the textbox
enable text box and label on selection
enable text box and label on selection  hello, Please tell me how to enable label and text box on selection of drop down list box. in drop down list box all values come from database. please reply
Show message and confirm dialog box
Show Message and Confirm Dialog Box - Swing Dialogs       This section show you how to display several... this   otherwise message dialog box will open with text "You clicked
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My...(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after submit i want to display other field. how to get it?? plz help me
Second tab should only show selected products from first tab
Second tab should only show selected products from first tab  ... users selected on the first tab. I started a function, but it currently only... to feature, and it will change the template accordingly. From there I get
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql... with text it is not possible. Please help me out. Thanks in advance
 

 

 

DMCA.com