Clicking on an item that isn't selected selects it. Clicking on
an item that is already selected deselects it. In the preceding
example, only one item from the scrolling list can be selected
at a time, since the second argument when creating the new scrolling
list is false. Selecting an item causes any other
selected item to be automatically deselected.

Note that the list in the example shown was created with four visible
rows. Once the list has been created, the number of visible rows
cannot be changed. A default List is created with
four rows, so that lst = new List() is equivalent to
list = new List(4, false).

Beginning with Java 1.1, the Abstract Window Toolkit
sends the List object all mouse, keyboard, and focus events
that occur over it. (The old AWT event model is being maintained
only for backwards compatibility, and its use is discouraged.)

When an item is selected or deselected by the user, AWT sends an instance
of ItemEvent to the list.
When the user double-clicks on an item in a scrolling list,
AWT sends an instance of ActionEvent to the
list following the item event. AWT also generates an action event
when the user presses the return key while an item in the
list is selected.

If an application wants to perform some action based on an item
in this list being selected or activated by the user, it should implement
ItemListener or ActionListener
as appropriate and register the new listener to receive
events from this list.

For multiple-selection scrolling lists, it is considered a better
user interface to use an external gesture (such as clicking on a
button) to trigger the action.

List

Creates a new scrolling list.
By default, there are four visible lines and multiple selections are
not allowed. Note that this is a convenience method for
List(0, false). Also note that the number of visible
lines in the list cannot be changed after it has been created.

List

Creates a new scrolling list initialized with the specified
number of visible lines. By default, multiple selections are
not allowed. Note that this is a convenience method for
List(rows, false). Also note that the number
of visible rows in the list cannot be changed after it has
been created.

List

Creates a new scrolling list initialized to display the specified
number of rows. Note that if zero rows are specified, then
the list will be created with a default of four rows.
Also note that the number of visible rows in the list cannot
be changed after it has been created.
If the value of multipleMode is
true, then the user can select multiple items from
the list. If it is false, only one item at a time
can be selected.

Parameters:

rows - the number of items to show.

multipleMode - if true,
then multiple selections are allowed;
otherwise, only one item can be selected at a time.

addItem

add

Adds the specified item to the the scrolling list
at the position indicated by the index. The index is
zero-based. If the value of the index is less than zero,
or if the value of the index is greater than or equal to
the number of items in the list, then the item is added
to the end of the list.

Parameters:

item - the item to be added;
if this parameter is null then the item is
treated as an empty string, ""

getSelectedObjects

select

public void select(int index)

Selects the item at the specified index in the scrolling list.

Note that this method should be primarily used to
initially select an item in this component.
Programmatically calling this method will not trigger
an ItemEvent. The only way to trigger an
ItemEvent is by user interaction.

minimumSize

addItemListener

Adds the specified item listener to receive item events from
this list. Item events are sent in response to user input, but not
in response to calls to select or deselect.
If listener l is null,
no exception is thrown and no action is performed.

addActionListener

Adds the specified action listener to receive action events from
this list. Action events occur when a user double-clicks
on a list item.
If listener l is null,
no exception is thrown and no action is performed.

removeActionListener

Removes the specified action listener so that it no longer
receives action events from this list. Action events
occur when a user double-clicks on a list item.
If listener l is null,
no exception is thrown and no action is performed.

processEvent

Processes events on this scrolling list. If an event is
an instance of ItemEvent, it invokes the
processItemEvent method. Else, if the
event is an instance of ActionEvent,
it invokes processActionEvent.
If the event is not an item event or an action event,
it invokes processEvent on the superclass.

Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.

A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.A script enabled browser is required for this page to function properly.