java.lang.Object | +--java.awt.Component | +--java.awt.List
The
List component presents the user with a
scrolling list of text items. The list can be set up so that
the user can choose either one item or multiple items.
For example, the code . . .
List lst = new List(4, false);
lst.add("Mercury");
lst.add("Venus");
lst.add("Earth");
lst.add("JavaSoft");
lst.add("Mars");
lst.add("Jupiter");
lst.add("Saturn");
lst.add("Uranus");
lst.add("Neptune");
lst.add("Pluto");
cnt.add(lst);
where cnt is a container, produces the following
scrolling list:
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.
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, 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, 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.
ItemEvent,
ItemListener,
ActionEvent,
ActionListener, Serialized Form
| Inner Class Summary | |
protected class |
List.AccessibleAWTList
List.AccessibleAWTList
|
| Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
List
copy-> new List()copy-> <List var> = new List();
|
|
List
copy-> new List( )copy-> <List var> = new List(<int rows>);
|
|
List
copy-> new List(, )copy-> <List var> = new List(<int rows>, <boolean multipleMode>);
|
|
| Method Summary | |
void |
add(String item)
copy-> .add( )copy-> <List>.add(<String item>);
|
void |
add(String item,
int index)
copy-> .add(, )copy-> <List>.add(<String item>, <int index>);
|
void |
addActionListener(ActionListener l)
copy-> .addActionListener( )copy-> <List>.addActionListener(<ActionListener l>);
|
void |
addItem(String item)
copy-> .addItem( )copy-> <List>.addItem(<String item>);
|
void |
addItem(String item,
int index)
copy-> .addItem(, )copy-> <List>.addItem(<String item>, <int index>);
|
void |
addItemListener(ItemListener l)
copy-> .addItemListener( )copy-> <List>.addItemListener(<ItemListener l>);
|
void |
addNotify()
copy-> .addNotify()copy-> <List>.addNotify();
|
boolean |
allowsMultipleSelections()
copy-> .allowsMultipleSelections()copy-> <boolean var>=<List>.allowsMultipleSelections();
|
void |
clear()
copy-> .clear()copy-> <List>.clear();
|
int |
countItems()
copy-> .countItems()copy-> <int var>=<List>.countItems();
|
void |
delItem(int position)
copy-> .delItem( )copy-> <List>.delItem(<int position>);
|
void |
delItems(int start,
int end)
copy-> .delItems(, )copy-> <List>.delItems(<int start>, <int end>);
|
void |
deselect(int index)
copy-> .deselect( )copy-> <List>.deselect(<int index>);
|
AccessibleContext |
getAccessibleContext()
copy-> .getAccessibleContext()copy-> <AccessibleContext var>=<List>.getAccessibleContext();
|
String |
getItem(int index)
copy-> .getItem( )copy-> <String var>=<List>.getItem(<int index>);
|
int |
getItemCount()
copy-> .getItemCount()copy-> <int var>=<List>.getItemCount();
|
String[] |
getItems()
copy-> .getItems()copy-> <String var>=<List>.getItems();
|
EventListener[] |
getListeners(Class listenerType)
copy-> .getListeners( )copy-> <EventListener var>=<List>.getListeners(<Class listenerType>);
|
Dimension |
getMinimumSize()
copy-> .getMinimumSize()copy-> <Dimension var>=<List>.getMinimumSize();
|
Dimension |
getMinimumSize(int rows)
copy-> .getMinimumSize( )copy-> <Dimension var>=<List>.getMinimumSize(<int rows>);
|
Dimension |
getPreferredSize()
copy-> .getPreferredSize()copy-> <Dimension var>=<List>.getPreferredSize();
|
Dimension |
getPreferredSize(int rows)
copy-> .getPreferredSize( )copy-> <Dimension var>=<List>.getPreferredSize(<int rows>);
|
int |
getRows()
copy-> .getRows()copy-> <int var>=<List>.getRows();
|
int |
getSelectedIndex()
copy-> .getSelectedIndex()copy-> <int var>=<List>.getSelectedIndex();
|
int[] |
getSelectedIndexes()
copy-> .getSelectedIndexes()copy-> <int var>=<List>.getSelectedIndexes();
|
String |
getSelectedItem()
copy-> .getSelectedItem()copy-> <String var>=<List>.getSelectedItem();
|
String[] |
getSelectedItems()
copy-> .getSelectedItems()copy-> <String var>=<List>.getSelectedItems();
|
Object[] |
getSelectedObjects()
copy-> .getSelectedObjects()copy-> <Object var>=<List>.getSelectedObjects();
|
int |
getVisibleIndex()
copy-> .getVisibleIndex()copy-> <int var>=<List>.getVisibleIndex();
|
boolean |
isIndexSelected(int index)
copy-> .isIndexSelected( )copy-> <boolean var>=<List>.isIndexSelected(<int index>);
|
boolean |
isMultipleMode()
copy-> .isMultipleMode()copy-> <boolean var>=<List>.isMultipleMode();
|
boolean |
isSelected(int index)
copy-> .isSelected( )copy-> <boolean var>=<List>.isSelected(<int index>);
|
void |
makeVisible(int index)
copy-> .makeVisible( )copy-> <List>.makeVisible(<int index>);
|
Dimension |
minimumSize()
copy-> .minimumSize()copy-> <Dimension var>=<List>.minimumSize();
|
Dimension |
minimumSize(int rows)
copy-> .minimumSize( )copy-> <Dimension var>=<List>.minimumSize(<int rows>);
|
protected String |
paramString()
copy-> .paramString()copy-> <String var>=<List>.paramString();
|
Dimension |
preferredSize()
copy-> .preferredSize()copy-> <Dimension var>=<List>.preferredSize();
|
Dimension |
preferredSize(int rows)
copy-> .preferredSize( )copy-> <Dimension var>=<List>.preferredSize(<int rows>);
|
protected void |
processActionEvent(ActionEvent e)
copy-> .processActionEvent( )copy-> <List>.processActionEvent(<ActionEvent e>);
|
protected void |
processEvent(AWTEvent e)
copy-> .processEvent( )copy-> <List>.processEvent(<AWTEvent e>);
|
protected void |
processItemEvent(ItemEvent e)
copy-> .processItemEvent( )copy-> <List>.processItemEvent(<ItemEvent e>);
|
void |
remove(int position)
copy-> .remove( )copy-> <List>.remove(<int position>);
|
void |
remove(String item)
copy-> .remove( )copy-> <List>.remove(<String item>);
|
void |
removeActionListener(ActionListener l)
copy-> .removeActionListener( )copy-> <List>.removeActionListener(<ActionListener l>);
|
void |
removeAll()
copy-> .removeAll()copy-> <List>.removeAll();
|
void |
removeItemListener(ItemListener l)
copy-> .removeItemListener( )copy-> <List>.removeItemListener(<ItemListener l>);
|
void |
removeNotify()
copy-> .removeNotify()copy-> <List>.removeNotify();
|
void |
replaceItem(String newValue,
int index)
copy-> .replaceItem(, )copy-> <List>.replaceItem(<String newValue>, <int index>);
|
void |
select(int index)
copy-> .select( )copy-> <List>.select(<int index>);
|
void |
setMultipleMode(boolean b)
copy-> .setMultipleMode( )copy-> <List>.setMultipleMode(<boolean b>);
|
void |
setMultipleSelections(boolean b)
copy-> .setMultipleSelections( )copy-> <List>.setMultipleSelections(<boolean b>);
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |