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 ... |
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.