13.17. Choice Menus
Choice entries produce pull-down menus with a single selection showing but with other options displayed when the user clicks with the mouse. These GUI controls are sometimes known as “combo boxes,” “drop-down list boxes,” or “option menus,” depending on the operating/windowing system you are using. Unlike buttons and check boxes, the entire Choice is not created with the constructor. Instead, a two-step process is required. The first step builds an empty menu, and the second adds elements to the menu with add. Creating a Choice menu and adding the menu to a panel is illustrated as follows:
Choice choice = new Choice(); choice.addItem("..."); choice.addItem("..."); ... somePanel.add(choice);
The Choice class has ...