how to know which jList is selected and according to that fetch the value

how to know which jList is selected and according to that fetch the value

Hi. I am Using netBeans..

I have 4 JLists (i.e jList1 , jList2, jList3 , jList4) in 4 different tabs in frame.

Each List has the value of employee_id from database (i successfully did it already) there are many field in tabs ( i.e rows of databse with employee id as primary key)

How to know which jList is selected so that i get the value of employee_id from the correct jList (i.e which is selected) to fetch data from database using selected employee id from selected jList with a common handler

A part of my program is

private void get_empid_detail(java.awt.event.MouseEvent evt) {                                  
   try {

   Class.forName("com.mysql.jdbc.Driver");
   Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/hrms","root","soft");

   Statement stmt=con.createStatement();

   boolean list1notSelected = jList1.isSelectionEmpty();     // caution or error whatever-> list1notSelected not in use
   boolean list2notSelected = jList2.isSelectionEmpty();     // same for list2notSelected
   boolean list3notSelected = jList3.isSelectionEmpty();     //same for list3notSelected
   boolean list4notSelected = jList4.isSelectionEmpty();     // same for list4notSelected

    String id;

    if ( list1notSelected = false){
         id  = (String) jList1.getSelectedValue();         // caution or error whetever
     }
   else if(list2notSelected = false){                           // every id in loop is not in use 
          id  = (String) jList2.getSelectedValue();
     }
   else if(list3notSelected = false){
          id  = (String) jList3.getSelectedValue();
     }
   else if(list4notSelected = false){
          id  = (String) jList3.getSelectedValue();
     }

     String sql1 = "Select * from emp where emp_id = '" + (id) + "'";  //error -> variable id might not have been initised
    ResultSet rs = stmt.executeQuery(sql1);
        while (rs.next())
    {
        String empid = rs.getString("emp_id");
        String f_name = rs.getString("first_name");
        String l_name = rs.getString("last_name");
        String qual = rs.getString("qualification");
        String dept = rs.getString("department");

        jTextField27.setText(""+ empid);
        jTextField28.setText(""+ f_name);
        jTextField29.setText(""+ l_name);
        jTextField30.setText(""+ qual);
        jTextField31.setText(""+ dept);

         }
}
catch(Exception e) {
    JOptionPane.showMessageDialog(this, e.getMessage());
}

Please Help . I have to submitt my project on monday and this is the only bug remaining.. Please.. Every part of software is working properly except this problem.

THANK YOU IN ADVANCE

View Answers









Related Tutorials/Questions & Answers:
how to know which jList is selected and according to that fetch the value
how to know which jList is selected and according to that fetch the value ... = window.adsbygoogle || []).push({}); How to know which jList is selected so that i get the value of employee_id from the correct jList (i.e which is selected
Display JList value selected from the JOptionPane
Display JList value selected from the JOptionPane In this section, we... that value in the JList. For this purpose, we have created a button and JList... and display the value of JList value
Advertisements
How to know the selected row from table - JSP-Interview Questions
How to know the selected row from table  hi Every one....i am... place one table data as hyperlink. now the problem here is how can i know the selected row in that table.  Hi Friend, Please clarify your
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 SQL Database Name is MHS, user=root, password=admin,table name is sub_comb... submit i want to display other field. how to get it?? plz help me
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...="destination" onchange="getPrice()"> <html:option value="0">...;<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...="destination" onchange="getPrice()"> <html:option value="0">...;<input type="text" value =" " property= "amount" id='pricecheck'/>
how to display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I... on first value I finished above code. ID: xx Name:xx xx is baesd on second and first value. But it is that l can't do that. now, l post my code
jList
jList  how to remove value from jlist after clicking on that value
how to display data from database according to entered value in search field
how to display data from database according to entered value in search... please. i don't know which line i have to add or change my code. thank you...;/b></td> <td>: <input type="text" name="bmi_value" id="BMI
how to update combobx's selected value to database with respect toselected multiple checkboxes
how to update combobx's selected value to database with respect toselected multiple checkboxes   suppose this if form1.jsp in which i am going... values which is selected from form1.jsp String languages=""; String box
change color according to the database value
change color according to the database value  any one know how to get values from database ( 1 or 0 ) and according to that change the color ( red or green) of given list
jList
jList  how to get the jlist values into jtextfield after clicking on the value?? plzz help   Here is an example that shows the selected value from the jlist to textfield. import java.awt.*; import javax.swing.*; import
jList
jList  how to add checkbox for every value in jlist having values populated from ms access database using java netbeans
Jlist
JcomboBox to a Jlist  How to transfer a data from a JcomboBox to a Jlist ? Each time I select 1 item from a JComboBox, it will display in a JList
. Display JavaScript dropdown selected value
. Display JavaScript dropdown selected value  How to get the selected...("dropdown").value; alert("You selected : " + dropdownValue); } <... dropdownValue we are storing the selected value by using
Java swing: get selected value from combobox
Java swing: get selected value from combobox In this tutorial, you will learn how to get selected value from combobox. The combobox provides the list... imposed an actionlistener on the combobox in order to get the selected value from
JList
JList  pls tell me about the concept the JList in corejava? and tell me a suitable example
SQL fetch value
SQL fetch value  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: (adsbygoogle
Java JComboBox Get Selected Item Value
how to get the selected item value form JComboBox. javax.swing.JComboBox.... In this tutorial we are discussing about how to store the selected item value... a simple example into which I shall get the combo box selected item value
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
as selected by the user which is already stored in the DB  The below... this code it is adding one more value to the dropdown box and showing as selected.... Can you please help me to show more than one value as selected pulling those
Populate listbox according to selection value from another selectbox
Populate listbox according to selection value from another selectbox  hi... I am developing my webproject in which i have 3 campus and each campus... listbox from database but campus list box will removes selected value.. please help
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 as selected by the user which is already stored in the DB   Hello, This is for Updating. I had two SQL queries one for only selected values
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable... the value of 'name1' as "Edit User" when calling the editUser function which
I am not able to display the selected value of my combobox
I am not able to display the selected value of my combobox   <?php echo "<select name=\"hello\">\n"; echo "<option value=\"NULL\">...; $select='<select size=1 name="unitcode">'; while($arrayRow = mysql_fetch
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list... value="">--- Select ---</option> </div> <?php mysql_connect
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list... value="">--- Select ---</option> </div> <?php mysql_connect
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list... value="">--- Select ---</option> </div> <?php mysql_connect
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
jlist in swings
jlist in swings  how to populate jlist with all the data retrieved from the ms access database?plzz help
Jlist and JTextfield
Jlist and JTextfield  How can we filter values from jlist by adding only a single letter in jtextfield such that when letter S is pressed in jtextfield then jlist should diplay all the values starting from letter S.I am using
how to get the image of a selected JRadioButton to another panel?
how to get the image of a selected JRadioButton to another panel?  how to get the image of a selected JRadioButton to another panel
I want to know the given class name exists in which jar file?
I want to know the given class name exists in which jar file?   I want to know the given class name exists in which jar file? C:\Program Files\IBM\IBMIMShared\plugins in this path around 600 jar files are there. i want to know
Struts2 and Hibernate Fetch Data Base Value
me what should i do for fetch the database value and shown on jsp page...") public > List<AdminProvideLeave>fetch1()// for > fetch the value from...Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am
Struts2 and Hibernate Fetch Data Base Value
me what should i do for fetch the database value and shown on jsp page...") public > List<AdminProvideLeave>fetch1()// for > fetch the value from...Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am
how to fetch data from servlet ????
how to fetch data from servlet ????  how to fetch data from servlet
how to by default chceckbox button is selected in struts
how to by default chceckbox button is selected in struts   i want to by default checkbox is selected please help me.. my is follwing <%@taglib... i want to all rows are by default selected (adsbygoogle
Create a JList Component in Java
Create a JList Component in Java       In this section, you will learn how to create a JList component of swing. JList is a component of GUI. It provides the multiple items
how to display selected checkboxes dynamically using jsp
how to display selected checkboxes dynamically using jsp  Hi friends i have a requirement that : in my JSP page i have radio buttons...) is available in DB,the respective radio button should be selected automatically
Setting Tool Tip Text for items in a JList Component
takes a integer value for locating item from the list according to the given point. getModel(): This is the method of JList class which holds the list of item which are shown in the JList component of Java Swing. It returns the list model
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide the coding step by step in mxml (ie) i am doing in flex .pls provide coding
JList Background Images..Urgent
JList Background Images..Urgent  I has done a JList that can change background color when i selected each of it, but if i want to change background image rather than background colors, how can i do it? Please help! my previous
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
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... answer me this q. urgently. With Regards, Vishwnath. (adsbygoogle
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... answer me this q. urgently. With Regards, Vishwnath. (adsbygoogle
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... me this q. urgently. With Regards, Vishwnath. (adsbygoogle
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... me this q. urgently. With Regards, Vishwnath. (adsbygoogle
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... me this q. urgently. With Regards, Vishwnath. (adsbygoogle
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier... the value from a link to a dropdown list. I want to set the dropdown list selected according to link. CODE: <% String hr = request.getParameter
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier... the value from a link to a dropdown list. I want to set the dropdown list selected according to link. CODE: print(" Blockquote <% String hr
Jtree connection with Jlist
Jtree connection with Jlist  I have a Jtree which contain different folders having files but the jtree will show only the folders. Now I want when I click a folder then its contained file will be shown in jList .How

Ads