12.8 Combo Boxes
A ComboBox implements a drop-down list. When the combo box appears, either no item or one item is displayed, along with a down arrow icon. When the user presses on the down arrow, the combo box “drops” open and displays a list of items, with a scroll bar for viewing more items. The user can select one item from the list. When the user selects an item, the list closes and only the selected item is displayed.
In this example, we allow the user to select a country from a combo box, and in response, we display an image of a typical food from the selected country. Figure 12.10 shows the window when our application begins.
Get Java Illuminated, 5th Edition 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.