Here is an example of a function handling an ActionPerformed event on a Combo Box.
private void onCategoryChanged(ActionEvent ae){
JComboBox cbCategory = (JComboBox)ae.getSource();
System.out.println(cbCategory.getSelectedIndex()); // Display the item index, 1st item index is 0
System.out.println((String)cbCategory.getSelectedItem()); // Display the string of the selected item
}
No comments:
Post a Comment