Whole document tree
java.awt
|
Inner Class Summary | |
protected class |
List.AccessibleAWTList
This class implements accessibility support for the List class. |
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()
Creates a new scrolling list. |
|
List(int rows)
Creates a new scrolling list initialized with the specified number of visible lines. |
|
List(int rows,
boolean multipleMode)
Creates a new scrolling list initialized to display the specified number of rows. |
Method Summary | |
void |
add(String item)
Adds the specified item to the end of scrolling list. |
void |
add(String item,
int index)
Adds the specified item to the the scrolling list at the position indicated by the index. |
void |
addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this list. |
void |
addItem(String item)
Deprecated. replaced by add(String) . |
void |
addItem(String item,
int index)
Deprecated. replaced by add(String, int) . |
void |
addItemListener(ItemListener l)
Adds the specified item listener to receive item events from this list. |
void |
addNotify()
Creates the peer for the list. |
boolean |
allowsMultipleSelections()
Deprecated. As of JDK version 1.1, replaced by isMultipleMode() . |
void |
clear()
Deprecated. As of JDK version 1.1, replaced by removeAll() . |
int |
countItems()
Deprecated. As of JDK version 1.1, replaced by getItemCount() . |
void |
delItem(int position)
Deprecated. replaced by remove(String)
and remove(int) . |
void |
delItems(int start,
int end)
Deprecated. As of JDK version 1.1, Not for public use in the future. This method is expected to be retained only as a package private method. |
void |
deselect(int index)
Deselects the item at the specified index. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this List. |
String |
getItem(int index)
Gets the item associated with the specified index. |
int |
getItemCount()
Gets the number of items in the list. |
String[] |
getItems()
Gets the items in the list. |
EventListener[] |
getListeners(Class listenerType)
Return an array of all the listeners that were added to the List with addXXXListener(), where XXX is the name of the listenerType
argument. |
Dimension |
getMinimumSize()
Determines the minimum size of this scrolling list. |
Dimension |
getMinimumSize(int rows)
Gets the minumum dimensions for a list with the specified number of rows. |
Dimension |
getPreferredSize()
Gets the preferred size of this scrolling list. |
Dimension |
getPreferredSize(int rows)
Gets the preferred dimensions for a list with the specified number of rows. |
int |
getRows()
Get the number of visible lines in this list. |
int |
getSelectedIndex()
Gets the index of the selected item on the list, |
int[] |
getSelectedIndexes()
Gets the selected indexes on the list. |
String |
getSelectedItem()
Get the selected item on this scrolling list. |
String[] |
getSelectedItems()
Get the selected items on this scrolling list. |
Object[] |
getSelectedObjects()
Returns the selected items on the list in an array of Objects. |
int |
getVisibleIndex()
Gets the index of the item that was last made visible by the method makeVisible . |
boolean |
isIndexSelected(int index)
Determines if the specified item in this scrolling list is selected. |
boolean |
isMultipleMode()
Determines whether this list allows multiple selections. |
boolean |
isSelected(int index)
Deprecated. As of JDK version 1.1, replaced by isIndexSelected(int) . |
void |
makeVisible(int index)
Makes the item at the specified index visible. |
Dimension |
minimumSize()
Deprecated. As of JDK version 1.1, replaced by getMinimumSize() . |
Dimension |
minimumSize(int rows)
Deprecated. As of JDK version 1.1, replaced by getMinimumSize(int) . |
protected String |
paramString()
Returns the parameter string representing the state of this scrolling list. |
Dimension |
preferredSize()
Deprecated. As of JDK version 1.1, replaced by getPreferredSize() . |
Dimension |
preferredSize(int rows)
Deprecated. As of JDK version 1.1, replaced by getPreferredSize(int) . |
protected void |
processActionEvent(ActionEvent e)
Processes action events occurring on this component by dispatching them to any registered ActionListener objects. |
protected void |
processEvent(AWTEvent e)
Processes events on this scrolling list. |
protected void |
processItemEvent(ItemEvent e)
Processes item events occurring on this list by dispatching them to any registered ItemListener objects. |
void |
remove(int position)
Remove the item at the specified position from this scrolling list. |
void |
remove(String item)
Removes the first occurrence of an item from the list. |
void |
removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this list. |
void |
removeAll()
Removes all items from this list. |
void |
removeItemListener(ItemListener l)
Removes the specified item listener so that it no longer receives item events from this list. |
void |
removeNotify()
Removes the peer for this list. |
void |
replaceItem(String newValue,
int index)
Replaces the item at the specified index in the scrolling list with the new string. |
void |
select(int index)
Selects the item at the specified index in the scrolling list. |
void |
setMultipleMode(boolean b)
Sets the flag that determines whether this list allows multiple selections. |
void |
setMultipleSelections(boolean b)
Deprecated. As of JDK version 1.1, replaced by setMultipleMode(boolean) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public List()
public List(int rows)
rows
- the number of items to show.public List(int rows, boolean multipleMode)
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.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.Method Detail |
public void addNotify()
java.awt.Component
public void removeNotify()
removeNotify
in class Component
java.awt.Component
Component.isDisplayable()
,
Component.addNotify()
public int getItemCount()
getItem(int)
public int countItems()
getItemCount()
.
public String getItem(int index)
index
- the position of the item.getItemCount()
public String[] getItems()
select(int)
,
deselect(int)
,
isIndexSelected(int)
public void add(String item)
item
- the item to be added.public void addItem(String item)
add(String)
.
public void add(String item, int index)
item
- the item to be added.
If this parameter is null then the item is
treated as an empty string, ""
.index
- the position at which to add the item.public void addItem(String item, int index)
add(String, int)
.
public void replaceItem(String newValue, int index)
newValue
- a new string to replace an existing item.index
- the position of the item to replace.public void removeAll()
remove(java.lang.String)
,
delItems(int, int)
public void clear()
removeAll()
.
public void remove(String item)
item
- the item to remove from the list.IllegalArgumentException
- if the item doesn't exist in the list.public void remove(int position)
position
- the index of the item to delete.ArrayIndexOutOfBoundsException
- if the position
is less than 0 or
greater than getItemCount()-1
add(String, int)
public void delItem(int position)
remove(String)
and remove(int)
.
public int getSelectedIndex()
-1
if no item is selected,
or if more that one item is selected.select(int)
,
deselect(int)
,
isIndexSelected(int)
public int[] getSelectedIndexes()
select(int)
,
deselect(int)
,
isIndexSelected(int)
public String getSelectedItem()
select(int)
,
deselect(int)
,
isIndexSelected(int)
public String[] getSelectedItems()
select(int)
,
deselect(int)
,
isIndexSelected(int)
public Object[] getSelectedObjects()
getSelectedObjects
in interface ItemSelectable
ItemSelectable
public void select(int index)
index
- the position of the item to select.getSelectedItem()
,
deselect(int)
,
isIndexSelected(int)
public void deselect(int index)
If the item at the specified index is not selected, or if the index is out of range, then the operation is ignored.
index
- the position of the item to deselect.select(int)
,
getSelectedItem()
,
isIndexSelected(int)
public boolean isIndexSelected(int index)
index
- the item to be checked.true
if the specified item has been
selected; false
otherwise.select(int)
,
deselect(int)
public boolean isSelected(int index)
isIndexSelected(int)
.
public int getRows()
public boolean isMultipleMode()
true
if this list allows multiple
selections; otherwise, false
.setMultipleMode(boolean)
public boolean allowsMultipleSelections()
isMultipleMode()
.
public void setMultipleMode(boolean b)
b
- if true
then multiple selections
are allowed; otherwise, only one item from
the list can be selected at once.isMultipleMode()
public void setMultipleSelections(boolean b)
setMultipleMode(boolean)
.
public int getVisibleIndex()
makeVisible
.makeVisible(int)
public void makeVisible(int index)
index
- the position of the item.getVisibleIndex()
public Dimension getPreferredSize(int rows)
rows
- number of rows in the list.Component.getPreferredSize()
public Dimension preferredSize(int rows)
getPreferredSize(int)
.
public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getPreferredSize()
public Dimension preferredSize()
getPreferredSize()
.
preferredSize
in class Component
public Dimension getMinimumSize(int rows)
rows
- number of rows in the list.Component.getMinimumSize()
public Dimension minimumSize(int rows)
getMinimumSize(int)
.
public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getMinimumSize()
public Dimension minimumSize()
getMinimumSize()
.
minimumSize
in class Component
public void addItemListener(ItemListener l)
addItemListener
in interface ItemSelectable
l
- the item listener.ItemEvent
,
ItemListener
,
removeItemListener(java.awt.event.ItemListener)
public void removeItemListener(ItemListener l)
removeItemListener
in interface ItemSelectable
l
- the item listener.ItemEvent
,
ItemListener
,
addItemListener(java.awt.event.ItemListener)
public void addActionListener(ActionListener l)
l
- the action listener.ActionEvent
,
ActionListener
,
removeActionListener(java.awt.event.ActionListener)
public void removeActionListener(ActionListener l)
l
- the action listener.ActionEvent
,
ActionListener
,
addActionListener(java.awt.event.ActionListener)
public EventListener[] getListeners(Class listenerType)
listenerType
argument. For example, to get all of the ItemListener(s) for the
given List l
, one would write:
ItemListener[] ils = (ItemListener[])(l.getListeners(ItemListener.class))If no such listener list exists, then an empty array is returned.
getListeners
in class Component
listenerType
- Type of listeners requestedprotected void processEvent(AWTEvent e)
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.processEvent
in class Component
e
- the event.ActionEvent
,
ItemEvent
,
processActionEvent(java.awt.event.ActionEvent)
,
processItemEvent(java.awt.event.ItemEvent)
protected void processItemEvent(ItemEvent e)
ItemListener
objects.
This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:
ItemListener
object is registered
via addItemListener
.
enableEvents
.
e
- the item event.ItemEvent
,
ItemListener
,
addItemListener(java.awt.event.ItemListener)
,
Component.enableEvents(long)
protected void processActionEvent(ActionEvent e)
ActionListener
objects.
This method is not called unless action events are enabled for this component. Action events are enabled when one of the following occurs:
ActionListener
object is registered
via addActionListener
.
enableEvents
.
e
- the action event.ActionEvent
,
ActionListener
,
addActionListener(java.awt.event.ActionListener)
,
Component.enableEvents(long)
protected String paramString()
paramString
in class Component
public void delItems(int start, int end)
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Component
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.