This is how I created my JComboBox -
String[] options = {"First", "Second" , "Third"};
JComboBox optionsCombo = new JComboBox(options);
When one of these items is selected, how do i get the index of the item which was selected ? I don't want the item the item that was selected.
indexes starts from 0,1,2,.. if you want to get the index of selected item then do this
will give selected index. Use this in combo box action listener
Use :
optionsCombo.getSelectedIndex();
inside actionListener Like this :