Guidelines Home Page >  Java Look and Feel Design Guidelines
Part III: The Components of the Java Foundation Classes
> 10: Basic Controls >
Combo Boxes
  Previous Next Contents/Index/Search

Combo Boxes

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


Combo Box Display

Users can close editable or noneditable combo boxes by clicking the drop-down arrow in the combo box again, selecting an item from the list, or clicking anywhere outside the combo box.

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."

Noneditable Combo Boxes

Noneditable combo boxes (sometimes called "list boxes" or "pop-up menus") display a list from which users can select one item.

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


Noneditable Combo Box

To make a selection, users have two options:

  • They can click the combo box to post the list, position the pointer over the desired option to highlight it, and click.
  • They can press the mouse button in the combo box (which posts the list), drag through the list to the desired choice and release the mouse button.

In either case, the currently selected item changes to reflects the choice.

  Use a noneditable combo box instead of a group of radio buttons or a list box if space is limited in your application.

Editable Combo Boxes

Editable combo boxes combine an editable text field with a drop-down arrow that users click to display an associated list of options.

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).

Figure 166   Editable Combo Box


Editable Combo Box

To make a selection, users have three options:

  • They can click the drop-down arrow to display the list, position the pointer over the desired option to highlight it, and click.
  • They can drag from the drop-down arrow to the desired selection and release the mouse button.
  • To make a customized selection, they can type text in the field and press Enter (or move focus to another component). If the list is open, it will close.

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 Blue, blue, or BLUE.

Java Look and Feel Design Guidelines, second edition.
Copyright 2001. Sun Microsystems, Inc. All Rights Reserved.
Previous Next Contents/Index/Search
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
Java 8 banner (182)