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);
Constructor
The Choice class has ...
Get Core Web Programming, Second 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.