Page 761 - Introduction to Programming with Java: A Problem Solving Approach
P. 761
Figure 17.15 Select-a-day combo box example
When a combo box first displays, the first item in its array is selected. So in the above example, Monday is
selected when the combo box first displays.
Methods
Here are the API headings and descriptions for the more popular JComboBox methods: public void setVisible(boolean flag)
Makes the combo box visible or invisible.
public void setEditable(boolean flag)
Makes the combo box’s top portion editable or non-editable.
public Object getSelectedItem()
Returns the item that is currently selected.
public void setSelectedItem(Object item)
Changes the currently selected item to the item that’s passed in.
public int getSelectedIndex()
Returns the index of the item that is currently selected.
17.14 JcomboBox Component 727
Initial display:
After a user clicks the down arrow:
down arrow
After a user clicks Thursday:
Apago PDF Enhancer