Hi, this has probably been asked before but I can't find any reference to it.In this sample of code I am trying to set the index of a combo box from an action_event triggered in another combo box.
I am having problems using the selectedIndex() method, sometimes it does not work like in this code:
void jComboBoxFitSel_itemStateChanged(ItemEvent e) {
if (jComboBoxFitSel.getSelectedIndex() == 4)
{
jLabel6.setText("pass 4");
jComboDia.removeAllItems();
jComboDia.insertItemAt("2.0",0);
jComboDia.insertItemAt("2.5",1);
jComboDia.insertItemAt("3.0",2);
jComboDia.insertItemAt("4.0",3);
jComboDia.insertItemAt("6.0",4);
jComboDia.insertItemAt("8.0",5);
jComboDia.insertItemAt("10.0",6);
jComboDia.insertItemAt("12.0",7);
jComboDia.insertItemAt("14.0",8);
jComboDia.insertItemAt("16.0",9);
jComboDia.insertItemAt("18.0",10);
jComboDia.insertItemAt("20.0",11);
jComboDia.insertItemAt("24.0",12);
jComboDia.setSelectedIndex(0);
}
else
{
jLabel6.setText("pass not 4");
jComboDia.removeAllItems();
jComboDia.insertItemAt("0.5",0);
jComboDia.insertItemAt("0.75",1);
jComboDia.insertItemAt("1.0",2);
jComboDia.insertItemAt("1.25",3);
jComboDia.insertItemAt("1.5",4);
jComboDia.insertItemAt("2.0",5);
jComboDia.insertItemAt("2.5",6);
jComboDia.insertItemAt("3.0",7);
jComboDia.insertItemAt("4.0",8);
jComboDia.insertItemAt("6.0",9);
jComboDia.insertItemAt("8.0",10);
jComboDia.insertItemAt("10.0",11);
jComboDia.insertItemAt("12.0",12);
jComboDia.insertItemAt("14.0",13);
jComboDia.insertItemAt("16.0",14);
jComboDia.insertItemAt("18.0",15);
jComboDia.insertItemAt("20.0",16);
jComboDia.insertItemAt("24.0",17);
jComboDia.setSelectedIndex(3);
}
}
}
when either one of these conditons are filled the jComboDia.setSelectedIndex command does not execute, is there some problem with trying to set an index in a combo box from another combo box.
Cheers, thanks for any help.
Jack
I am having problems using the selectedIndex() method, sometimes it does not work like in this code:
void jComboBoxFitSel_itemStateChanged(ItemEvent e) {
if (jComboBoxFitSel.getSelectedIndex() == 4)
{
jLabel6.setText("pass 4");
jComboDia.removeAllItems();
jComboDia.insertItemAt("2.0",0);
jComboDia.insertItemAt("2.5",1);
jComboDia.insertItemAt("3.0",2);
jComboDia.insertItemAt("4.0",3);
jComboDia.insertItemAt("6.0",4);
jComboDia.insertItemAt("8.0",5);
jComboDia.insertItemAt("10.0",6);
jComboDia.insertItemAt("12.0",7);
jComboDia.insertItemAt("14.0",8);
jComboDia.insertItemAt("16.0",9);
jComboDia.insertItemAt("18.0",10);
jComboDia.insertItemAt("20.0",11);
jComboDia.insertItemAt("24.0",12);
jComboDia.setSelectedIndex(0);
}
else
{
jLabel6.setText("pass not 4");
jComboDia.removeAllItems();
jComboDia.insertItemAt("0.5",0);
jComboDia.insertItemAt("0.75",1);
jComboDia.insertItemAt("1.0",2);
jComboDia.insertItemAt("1.25",3);
jComboDia.insertItemAt("1.5",4);
jComboDia.insertItemAt("2.0",5);
jComboDia.insertItemAt("2.5",6);
jComboDia.insertItemAt("3.0",7);
jComboDia.insertItemAt("4.0",8);
jComboDia.insertItemAt("6.0",9);
jComboDia.insertItemAt("8.0",10);
jComboDia.insertItemAt("10.0",11);
jComboDia.insertItemAt("12.0",12);
jComboDia.insertItemAt("14.0",13);
jComboDia.insertItemAt("16.0",14);
jComboDia.insertItemAt("18.0",15);
jComboDia.insertItemAt("20.0",16);
jComboDia.insertItemAt("24.0",17);
jComboDia.setSelectedIndex(3);
}
}
}
when either one of these conditons are filled the jComboDia.setSelectedIndex command does not execute, is there some problem with trying to set an index in a combo box from another combo box.
Cheers, thanks for any help.
Jack