kodejava-swing/src/main/java/org/kodejava/example/swing/ComboBoxSelectionChange.java
public void itemStateChanged(ItemEvent event) {
                JComboBox comboBox = (JComboBox) event.getSource();

                // The item affected by the event.
                Object item = event.getItem();

                textArea.setText("Affected items: " + item.toString());

                if (event.getStateChange() == ItemEvent.SELECTED) {
                    textArea.setText(item.toString() + " selected.");
                }

                if (event.getStateChange() == ItemEvent.DESELECTED) {
                    textArea.setText(item.toString() + " deselected.");
                }
            }
// Listening if a new items of the combo box has been selected.
Listening if a new items of the combo box has been selected.
Listening if a new items of the combo box has been selected .
public void itemStateChanged(ItemEvent event) {
                JComboBox comboBox = (JComboBox) event.getSource();
                Object item = event.getItem();
                textArea.setText("Affected items: " + item.toString());
                if (event.getStateChange() == ItemEvent.SELECTED) {
                    textArea.setText(item.toString() + " selected.");
                }
                if (event.getStateChange() == ItemEvent.DESELECTED) {
                    textArea.setText(item.toString() + " deselected.");
                }
            }
public void itemStateChanged ( ItemEvent event ) { JComboBox comboBox = ( JComboBox ) event . getSource ( ) ; Object item = event . getItem ( ) ; textArea . setText ( "Affected items: " + item . toString ( ) ) ; if ( event . getStateChange ( ) == ItemEvent . SELECTED ) { textArea . setText ( item . toString ( ) + " selected." ) ; } if ( event . getStateChange ( ) == ItemEvent . DESELECTED ) { textArea . setText ( item . toString ( ) + " deselected." ) ; } }
Listening if a new items of the combo box has been selected.
Listening if a new items of the combo box has been selected .
// The item affected by the event.