Question

I don't understand this - how to get the first selected item?

class ItemChangeListener implements ItemListener{
        @Override
        public void itemStateChanged(ItemEvent event) {
           if (event.getStateChange() == ItemEvent.SELECTED) {
              Object item = event.getItem();
 ---->        if()
                  JOptionPane.showMessageDialog(null, "AW");
                    //UpdateTableStudent();
                else
                  JOptionPane.showMessageDialog(null, item);
                    //SearchTableStudent();
              }
        }       
   }

What to input there when I select the first item?

I mean the index 0... because there is no

event.getSelectedIndex() == 0
Was it helpful?

Solution

there's a

jcomboBox.getSelectedItem();

or jcomboBox.getSelectedIndex();

though...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top