I have created two select list (Combo box). BankName and BranchName.
BankName is using LOV with query to display bankname.
This is working fine.
Now when i select Bank name i want to display selected branches of that bank in Branchname combo.How to display values in second combo basis on first combo value click.It should refresh after click
Please reply

Recommended Answers

All 3 Replies

add ActionListener to jcbBankName
inside ActionPerformed method:
- check jcbBankName.getSelectedItem()
- force new model - jcbBranchName.setModel(...your model..relate to checked value)

in the constructor of your class, do not forget to set default values for both the comboboxes

i have this code will u plz help me

String obj =(String)jComboBox1.getSelectedItem();

System.out.println(obj);

res=stat.executeQuery("Select flight from main where Route= '"+obj+"' ");
String [] array2=new String[5];

for(int i=0;res.next();i++)
array2=res.getString(2);

jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(array2));

where is this code? whats wrong with it, ie how can we "help"? is it in an actionListener???

oh, and please use code tags

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.