![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
![]() |
A JList object is a user-interface component that presents a list of items. From this list, the user can select one or more items. In the Swing 0.5 release, the component called JListBox has been renamed JList, and no longer includes scrolling support. To make a scrolling list, write code something like the following:
JList list = new JList(new Object[]{"one", "two", "free", "four"}); JScrollPane listbox = new JScrollPane(list);
The JList control class provides basic support for presenting a list of single-line strings. It supports both single selections and multiple selections, along with the usual list of operations for adding and removing string items from lists.
JList shares the following features with other kinds of list and list-box controls:
With the help of the ListCellRenderer interface, your application can cause the items in a list box to be rendered in various user-selectable forms. The most common kinds of renderings displayed in list boxes are strings and icons. A list box can display both strings and icons. To see how strings and icons can be used in list boxes, run the SwingSet demonstration program provided with Swing and experiment with the lists provided on the page that demonstrates list boxes.
For more information about the JList class, see the JList API.
Version 0.5. Last modified 10/1/97.
Copyright © 1995-97 Sun
Microsystems, Inc. All Rights Reserved.