
 |
Chapter 19 java.awt Reference |
 |
List
Name
List
The List is a Component
that provides a scrollable list of choices to select from. A List
can be in one of two modes: single selection mode, in which only one item
may be selected at a time; and multiple selection mode, in which several
items may be selected at one time. A list does not necessarily display
all of the choices at one time; one of the constructors lets you specify
the number of choices to display simultaneously. Although the changes in
1.1 are extensive, almost all of them can be boiled down to (1) using the
1.1 event model, and (2) standardizing method names (e.g. set/get
pairs).
- Description
-
Constructs a List object in
single-selection mode.
- Parameters
-
- rows
-
Requested number of rows to display.
- Description
-
Constructs a List object with
the specified number of rows, in single-selection mode.
- Parameters
-
- rows
-
Requested number of rows to display.
- multipleSelections
-
true to allow
multiple selections; false
to select one item at a time.
- Description
-
Constructs a List object.
- Parameters
-
- item
-
Text for entry to add.
- Description
-
Adds a new entry to the available choices.
- Parameters
-
- item
-
Text for entry to add.
- index
-
Position at which to add entry; the first entry has an
index of zero.
- Description
-
Adds a new entry to the available choices at the designated position.
- Parameters
-
- l
-
An object that implements the ActionListener
interface.
- Description
-
Add a listener for the action event.
- Parameters
-
- item
-
Text for entry to add.
- Description
-
Replaced by add(String).
- Parameters
-
- item
-
Text for entry to add.
- index
-
Position at which to add entry; the first entry has an
index of zero.
- Description
-
Replaced by add(String, int).
- Parameters
-
- l
-
The listener to be added.
- Implements
-
ItemSelectable.addItemListener(ItemListener
l)
- Description
-
Adds a listener for the ItemEvent
objects this List fires off.
- Overrides
-
Component.addNotify()
- Description
-
Creates List's peer.
- Returns
-
true if multi-selection active,
false otherwise. Replaced by
isMultipleMode().
- Description
-
Clears all the entries out of the List.
Replaced by removeAll().
- Returns
-
Number of items in the List.
Replaced by getItemCount().
- Parameters
-
- position
-
Position of item to delete.
- Description
-
Removes a single entry from the List.
Replaced by remove(int) and
remove(String).
- Parameters
-
- start
-
Starting position of entries to delete.
- end
-
Ending position of entries to delete.
- Description
-
Removes a set of entries from the List.
- Parameters
-
- index
-
Position to deselect.
- Description
-
Deselects the entry at the designated position, if selected.
- Parameters
-
- index
-
Position of entry to get.
- Throws
-
- ArrayIndexOutOfBoundsException
-
If
index is invalid.
- Returns
-
String for entry at given position.
- Returns
-
Number of items in the List.
- Returns
-
The string items in the List.
- Returns
-
The minimum dimensions of the List.
- Parameters
-
- rows
-
Number of rows within List
to size.
- Returns
-
The minimum dimensions of a List
of the given size.
- Returns
-
The preferred dimensions of the List.
- Parameters
-
- rows
-
Number of rows within List
to size.
- Returns
-
The preferred dimensions of a List
of the given size.
- Returns
-
Returns number of rows requested to be displayed in List.
- Returns
-
Position of currently selected entry, or -1 if nothing is selected, or
if multiple entries are selected.
- Returns
-
An array whose elements are the indices of the currently selected entries.
- Returns
-
Currently selected entry as a String, or null if nothing is selected, or if multiple entries are selected.
- Returns
-
An array of strings whose elements are the labels of the currently selected
entries.
- Implements
-
ItemSelectable.getSelectedObjects()
- Returns
-
An array of strings whose elements are the labels of the currently selected
entries.
- Returns
-
The last index from a call to makeVisible().
- Parameters
-
- index
-
Position to check.
- Returns
-
true if index selected, false
otherwise.
- Description
-
Checks to see if a particular entry is currently selected.
- Returns
-
true if multiple selection
is allowed, false otherwise.
- Parameters
-
- index
-
Position to check.
- Returns
-
true if index selected, false
otherwise.
- Description
-
Checks to see if a particular entry is currently selected. Replaced by
isIndexSelected(int).
- Parameters
-
- index
-
Position to make visible on screen.
- Description
-
Ensures an item is displayed on the screen.
- Returns
-
The minimum dimensions of the List.
Replaced by getMinimumSize().
- Parameters
-
- rows
-
Number of rows within List
to size.
- Returns
-
The minimum dimensions of a List
of the given size. Replaced by getMinimumSize(int).
- Returns
-
The preferred dimensions of the List.
Replaced by getPreferredSize().
- Parameters
-
- rows
-
Number of rows within List
to size.
- Returns
-
The preferred dimensions of a List
of the given size. Replaced by getPreferredSize(int).
- Parameters
-
- position
-
Position of item to remove.
- Description
-
Removes a single entry from the List.
- Parameters
-
- item
-
Item to remove.
- Throws
-
- IllegalArgumentException
-
If
item is not in the List.
- Description
-
Removes a single entry from the List.
- Parameters
-
- l
-
One of this List's
ActionListeners.
- Description
-
Remove an action event listener.
- Description
-
Removes all items from the List.
- Parameters
-
- l
-
The listener to be removed.
- Implements
-
ItemSelectable.removeItemListener (ItemListener l)
- Description
-
Removes the specified ItemListener
so it will not receive ItemEvent
objects from this List.
- Description
-
Destroys the peer of the List.
- Parameters
-
- newItem
-
Label for entry to add.
- index
-
Position of entry to replace.
- Description
-
Replaces the contents at a particular position with a new entry.
- Parameters
-
- position
-
Position to make selected entry.
- Description
-
Makes the given entry the selected one for the List.
- Parameters
-
- b
-
true to enable
multiple selections; false
to disable multiple selections.
- Description
-
Changes List's selection
mode based upon flag.
- Parameters
-
- value
-
true to enable
multiple selections; false
to disable multiple selections.
- Description
-
Changes List's selection
mode based upon flag. Replaced by setMultipleMode(boolean).
- Returns
-
String with current settings of List.
- Overrides
-
Component.paramString()
- Description
-
Helper method for toString()
to generate string of current settings.
- Parameters
-
- e
-
The action event to process.
- Description
-
Action events are passed to this method for processing. Normally, this
method is called by processEvent().
- Parameters
-
- e
-
The event to process.
- Description
-
Low-level AWTEvents are passed
to this method for processing.
- Parameters
-
- e
-
The item event to process.
- Description
-
Item events are passed to this method for processing. Normally, this method
is called by processEvent().
Component, Dimension,
ItemSelectable, String
|