hello everyone just need a bit of help here:
JComboBox comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] {"Select", "Single", "Twin", "Double", "Suit", "Conference"}));
String[] single = d.getAvaSinglelist().toArray(new String[d.getAvaSinglelist().size()]);
String[] Dbroon = d.getAvaDoublelist().toArray(new String[d.getAvaDoublelist().size()]);
String[] Twin = d.getAvaTwinlist().toArray(new String[d.getAvaTwinlist().size()]);
String[] Suit = d.getAvaSuitslist().toArray(new String[d.getAvaSuitslist().size()]);
String[] conf = d.getAvaConferencelist().toArray(new String[d.getAvaConferencelist().size()]);
JComboBox comboBox_1 = new JComboBox();
if(comboBox.getSelectedItem().equals("Single")){
comboBox_1.setModel(new DefaultComboBoxModel(single));
}
if(comboBox.getSelectedItem().equals("Twin")){
comboBox_1.setModel(new DefaultComboBoxModel(Dbroon));
}
if(comboBox.getSelectedItem().equals("Double")){
comboBox_1.setModel(new DefaultComboBoxModel(Twin));
}
if(comboBox.getSelectedItem().equals("Suit")){
comboBox_1.setModel(new DefaultComboBoxModel(Suit));
}
if(comboBox.getSelectedItem().equals("Conference")){
comboBox_1.setModel(new DefaultComboBoxModel(conf));
}
so what i want to do and cant find out how is to refresh the second combobox based on the selected item of the first one in a dynamic mode but as you guys can see also i have no idea every tip is welcome
Add an ActionListener
to your first JComboBox
. Then add the logic for updating the second combo box inside that code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.