JComboBox Class
Package: javax.swing
Using this creates a combo box, which is a combination of a text field and a drop-down list from which the user can choose a value. If the text field portion of the control is editable, the user can enter a value in the field or edit a value retrieved from the drop-down list. Making the text field uneditable is common, however, and in that case, the user must pick one of the values from the list.
Figure 5-5 shows a simple combo box.

Figure 5-5
Constructors
|
Constructor |
Description |
|
|
Creates an empty combo box |
|
|
Creates a combo box and fills it with the values in the array |
|
|
Creates a combo box and fills it with the values in the vector |
Methods
|
Method |
Description |
|
|
Adds an action listener to the combo box. |
|
|
Adds the item to the combo box. |
|
|
Adds an item listener to the combo box. |
|
|
Returns the item at the specified index. |
|
|
Returns the number of items in the combo box. |
|
|
Returns the index of the selected item. |
|
|
Returns the selected item. |
|
|
Inserts an item at ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access