13.18. List Boxes

List boxes present scrolling lists from which the user can select an item (single-selectable lists) or several items (multiple-selectable lists). As with Choice menus, you first create an empty list, then add items to it through add, as below:

List list = new List();
list.addItem("...");
list.addItem("...");
...
add(list);

Constructors

The List class has three constructors.

public List()

public List(int rows)

public List(int rows, boolean multiSelectable)

The first constructor creates a single-selectable list box with a platform-dependent number of rows and a platform-dependent width. The second constructor creates a single-selectable list box with the specified number of rows and a platform-dependent width.

The last constructor ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.