Java Sun >
Guidelines Home Page >  Java Look and Feel Design Guidelines
>
Part III: The Components of the Java Foundation Classes
>
12: Selectable Lists, Tables, and Tree Components
  Previous Next Contents/Index/Search


12: Selectable Lists, Tables, and Tree Components

A selectable list is a one-column arrangement of items in which the items users select are designated for a subsequent action, usually in an associated component such as a table or a text field. Tables and trees provide a way to organize related information so that users can easily compare the data. A table is a two-dimensional arrangement of data. A tree component is an outline of hierarchical relationships.

Figure 184   Selectable List, Table, and Tree Component

 

List, Table, and Tree

Selectable Lists

Selectable lists are one-column collections of data in which selected items are designated for a subsequent action. Command buttons can operate on this selection. When users make another selection, any previous selection is deselected. This is the same way selection works for many other objects, including text. List boxes, which are also implemented with the JList component, have a different selection model. In list boxes, the choices that the user makes are persistent.)

In selectable lists, as in list boxes, a single item, a single range, or multiple ranges can be selected. See Selection Models for List Components for details.

  Provide users with as much flexibility in making selections as makes sense for your application.

  Selectable lists are created using the JList component.

Selectable Lists and Associated Tables

Selectable lists are appropriate when you want a user to select a few items from a long list so that your application can then display details of the selected items in a table. The user selects an item in the list on the left (in left-to-right locales) and presses the Add button. The selected item is removed from the list on the left and appears (with additional detail) in the table on the right. The most recently moved item appears selected in the table, as shown in the following figure.

Figure 185   Selectable List and Associated Table

 

Selectable List and Its Table

Selectable Lists and Associated Text Fields

Selectable lists are also typically used in file choosers. Users select an item from a list of files, and an editable text field reflects the choice, as shown in the following figure.

Figure 186   Selectable List in File Chooser at Time of Selection

 

List in File Chooser at Selection

When keyboard focus moves to the editable text field, the selected item remains in the list, but the highlighting is removed, as shown in the following figure.

Figure 187   Selectable List in File Chooser After Change in Keyboard Focus

 

List in File Chooser After Focus Change

 


Note — Typically, double-clicking in a selectable list activates a dialog box's default command. You must program this behavior explicitly; the JFC does not provide it automatically.


Except for selection behavior, selectable lists are the same as list boxes, described in List Boxes.

  Be sure to put your selectable list in a scroll pane if it contains too many items to display all at once.

  Always display a whole number of lines in scrolling lists.


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
JavaOne Banner
Java 8 banner (182)