The List class provides a compact, multiple-choice, scrolling selection list. Unlike the . Choice object, which shows only the single selected item in the menu, a List object can be constructed to show any number of choices in the visible window. It can also be created to allow multiple selections. List provides these constructors.
List(int num Rows)
List(int num Rows, boolean multiple decret)’
The first version creates a List control that allow’, only one item to be selected at any
one time. In the second form, the value of num Rows specifies the number of entries in the list that will always be visible (others can be scrolled into view as needed). In the third form, if is true” then the user may select two or more items at a time. If it is false, then only one item may be selected. To add a selection to the list, call add(). It has the following two forms: .void add(string name) void add (String name, int index. Here, name is the name of the item added to the list. The first form adds items to the end of the list. The second form adds the item at the index specified by index. Indexing begins at zero. You can specify add the item to the end of the list For lists that allow only single selection, you can determine which item is currently selected by calling either. or These methods are shown here:
String get Selected Item( )
int get Selected Index( )
The get Selected Item( ) methoreturns a string containing the name of the item. If
more than one item is selected gr if no selection has yet been made, null is returned.
‘getS~lectedlndex( ) returns the index of the item. The first item is at index O.If more
than one item is selected, or if no selection has yet been made, -1is returned.
. For lists that allow multiple selection, you must use either gctSelcctedItems( ) or
getSelectedInd’exes( ), shown here, to determine the current selections:
String[ ] getSelectedltems( )
int[ J.getSelectedIndexes( )
getSelectedIteins( ) returns an array containing the names of the currently selected
items. getSelectedIndexes( ) returns an array containing the indexes of the currently
Managing Scroll Bars
Scroll bars are used to select continuous values between a specified minimum and
maximum. Scroll bars may be oriented horizontally or vertically. A scroll bar is actually a composite of several individual parts. Each end has an arrow that you can click to move the current value of the scroll bar one unit in the direction of the arrow. value . of the scroll bar relative to its minimum and maximum values is indicated by the slider box. (or thumb) for the scroll bar. The slider box can be dragged by the user to a new position. The scroll bar will then reflect this value. In the background space on either side of the