| JSC >
Guidelines Home Page > Java Look and Feel Design Guidelines >
Part III: The Components of the Java Foundation Classes > 10: Basic Controls >
A combo box is a component with a drop-down arrow that users click to display an associated list of choices. If the list is too long to display fully, a vertical scrollbar appears. The current selection appears in an editable or noneditable text field next to the drop-down arrow. The user displays the list by clicking or dragging the drop-down arrow.
The currently selected item appears in the pulled-down combo box. As a user moves the pointer over the list, each option under the pointer is highlighted. If the user selects an option from the list, that option replaces the current selection. In the following figure, the currently selected item is Vanilla, and the Guanabana option will replace Vanilla when the mouse button is lifted or the spacebar is pressed.Figure 164 Combo Box Display
For a list of keyboard operations appropriate for combo boxes, see Table 16.
You can use combo boxes to provide a way for users to indicate a choice from a set of mutually exclusive options. Noneditable combo boxes enable users to select one item from a limited set of items. Editable combo boxes provide users the additional option of typing in an item that might or might not be on the list.
Use headline capitalization for the text in the combo box list.
To facilitate keyboard access, provide labels with mnemonics for combo boxes.
You can specify the maximum number of items to be displayed in a combo box before a scrollbar appears. The default is 8; however, if you know that your list contains 9 or 10 items, it is good practice to display all the items so users don't have to scroll to see just one or two additional items.
In the JFC, the term "combo box" includes both of what Microsoft Windows applications call "list boxes" and "combo boxes."
The following figure shows a noneditable combo box with a drop-down arrow to the right of the currently selected item. (Note the gray background in the default Java look and feel theme, indicating that users cannot edit text.)Figure 165 Noneditable Combo Box
Use a noneditable combo box instead of a group of radio buttons or a list box if space is limited in your application.
As shown in Figure 166, editable combo boxes initially appear as editable text fields with a drop-down arrow. The white background of the editable combo box indicates that users can type, select, and edit text.
Click here to view the corresponding code for Figure 166 (also available on the book's companion CD-ROM).
You can use an editable combo box to save users time by making the most likely menu choices available while still enabling users to type other values in the text field. An example might be the specification of a font size. The combo box might initially display a current size of 11. Users could select from a list of standard sizes (8, 9. 10, 12, 14, 16, or 18 points) or type in their own values--for instance, 22 points.
Whenever possible, interpret user input into an editable combo box in a case- insensitive way. For example, it should not matter whether the user types
|Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.