All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.List

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.List

public class List
extends Component
implements ItemSelectable
A scrolling list of text items.


Constructor Index

 o List()
Creates a new scrolling list initialized with no visible Lines or multiple selections.
 o List(int)
Creates a new scrolling list initialized with the specified number of visible lines and a boolean stating whether multiple selections are allowed or not.
 o List(int, boolean)
Creates a new scrolling list initialized with the specified number of visible lines and a boolean stating whether multiple selections are allowed or not.

Method Index

 o add(String)
Adds the specified item to the end of scrolling list.
 o add(String, int)
Adds the specified item to the scrolling list at the specified position.
 o addActionListener(ActionListener)
Adds the specified action listener to receive action events from this list.
 o addItem(String)
Adds the specified item to the end of scrolling list.
 o addItem(String, int)
Adds the specified item to the scrolling list at the specified position.
 o addItemListener(ItemListener)
Adds the specified item listener to recieve item events from this list.
 o addNotify()
Creates the peer for the list.
 o allowsMultipleSelections()
Deprecated.
 o clear()
Deprecated.
 o countItems()
Deprecated.
 o delItem(int)
Removes an item from the list.
 o delItems(int, int)
Deprecated.
 o deselect(int)
Deselects the item at the specified index.
 o getItem(int)
Gets the item associated with the specified index.
 o getItemCount()
Returns the number of items in the list.
 o getItems()
Returns the items in the list.
 o getMinimumSize()
Returns the minimum dimensions needed for the list.
 o getMinimumSize(int)
Returns the minimum dimensions needed for the amount of rows in the list.
 o getPreferredSize()
Returns the preferred dimensions needed for the list.
 o getPreferredSize(int)
Returns the preferred dimensions needed for the list with the specified amount of rows.
 o getRows()
Returns the number of visible lines in this list.
 o getSelectedIndex()
Get the selected item on the list or -1 if no item is selected.
 o getSelectedIndexes()
Returns the selected indexes on the list.
 o getSelectedItem()
Returns the selected item on the list or null if no item is selected.
 o getSelectedItems()
Returns the selected items on the list in an array of Strings.
 o getSelectedObjects()
Returns the selected items on the list in an array of Objects.
 o getVisibleIndex()
Gets the index of the item that was last made visible by the method makeVisible.
 o isIndexSelected(int)
Returns true if the item at the specified index has been selected; false otherwise.
 o isMultipleMode()
Returns true if this list allows multiple selections.
 o isSelected(int)
Deprecated.
 o makeVisible(int)
Forces the item at the specified index to be visible.
 o minimumSize()
Deprecated.
 o minimumSize(int)
Deprecated.
 o paramString()
Returns the parameter String of this list.
 o preferredSize()
Deprecated.
 o preferredSize(int)
Deprecated.
 o processActionEvent(ActionEvent)
Processes action events occurring on this component by dispatching them to any registered ActionListener objects.
 o processEvent(AWTEvent)
Processes events on this list.
 o processItemEvent(ItemEvent)
Processes item events occurring on this list by dispatching them to any registered ItemListener objects.
 o remove(int)
Removes an item from the list.
 o remove(String)
Remove the first occurrence of item from the list.
 o removeActionListener(ActionListener)
Removes the specified action listener so it no longer receives action events from this list.
 o removeAll()
Removes all items from the list.
 o removeItemListener(ItemListener)
Removes the specified item listener so it no longer receives item events from this list.
 o removeNotify()
Removes the peer for this list.
 o replaceItem(String, int)
Replaces the item at the given index.
 o select(int)
Selects the item at the specified index.
 o setMultipleMode(boolean)
Sets whether this list should allow multiple selections or not.
 o setMultipleSelections(boolean)
Deprecated.

Constructors

 o List
  public List()
Creates a new scrolling list initialized with no visible Lines or multiple selections.

 o List
  public List(int rows)
Creates a new scrolling list initialized with the specified number of visible lines and a boolean stating whether multiple selections are allowed or not.

Parameters:
rows - the number of items to show.
multipleMode - if true then multiple selections are allowed.
 o List
  public List(int rows,
              boolean multipleMode)
Creates a new scrolling list initialized with the specified number of visible lines and a boolean stating whether multiple selections are allowed or not.

Parameters:
rows - the number of items to show.
multipleMode - if true then multiple selections are allowed.

Methods

 o addNotify
  public void addNotify()
Creates the peer for the list. The peer allows us to modify the list's appearance without changing its functionality.

Overrides:
addNotify in class Component
 o removeNotify
  public void removeNotify()
Removes the peer for this list. The peer allows us to modify the list's appearance without changing its functionality.

Overrides:
removeNotify in class Component
 o getItemCount
  public int getItemCount()
Returns the number of items in the list.

See Also:
getItem
 o countItems
  public int countItems()
Note: countItems() is deprecated. As of JDK version 1.1, replaced by getItemCount().

 o getItem
  public String getItem(int index)
Gets the item associated with the specified index.

Parameters:
index - the position of the item
See Also:
getItemCount
 o getItems
  public synchronized String[] getItems()
Returns the items in the list.

See Also:
select, deselect, isIndexSelected
 o add
  public void add(String item)
Adds the specified item to the end of scrolling list.

Parameters:
item - the item to be added
 o addItem
  public void addItem(String item)
Adds the specified item to the end of scrolling list.

Parameters:
item - the item to be added
 o add
  public synchronized void add(String item,
                               int index)
Adds the specified item to the scrolling list at the specified position.

Parameters:
item - the item to be added
index - the position at which to put in the item. The index is zero-based. If index is -1 then the item is added to the end. If index is greater than the number of items in the list, the item gets added at the end.
 o addItem
  public synchronized void addItem(String item,
                                   int index)
Adds the specified item to the scrolling list at the specified position.

Parameters:
item - the item to be added
index - the position at which to put in the item. The index is zero-based. If index is -1 then the item is added to the end. If index is greater than the number of items in the list, the item gets added at the end.
 o replaceItem
  public synchronized void replaceItem(String newValue,
                                       int index)
Replaces the item at the given index.

Parameters:
newValue - the new value to replace the existing item
index - the position of the item to replace
 o removeAll
  public synchronized void removeAll()
Removes all items from the list.

See Also:
remove, delItems
 o clear
  public synchronized void clear()
Note: clear() is deprecated. As of JDK version 1.1, replaced by removeAll().

 o remove
  public synchronized void remove(String item)
Remove the first occurrence of item from the list.

Parameters:
item - the item to remove from the list
Throws: IllegalArgumentException
If the item doesn't exist in the list.
 o remove
  public synchronized void remove(int position)
Removes an item from the list.

 o delItem
  public synchronized void delItem(int position)
Removes an item from the list.

 o getSelectedIndex
  public synchronized int getSelectedIndex()
Get the selected item on the list or -1 if no item is selected.

See Also:
select, deselect, isIndexSelected
 o getSelectedIndexes
  public synchronized int[] getSelectedIndexes()
Returns the selected indexes on the list.

See Also:
select, deselect, isIndexSelected
 o getSelectedItem
  public synchronized String getSelectedItem()
Returns the selected item on the list or null if no item is selected.

See Also:
select, deselect, isIndexSelected
 o getSelectedItems
  public synchronized String[] getSelectedItems()
Returns the selected items on the list in an array of Strings.

See Also:
select, deselect, isIndexSelected
 o getSelectedObjects
  public Object[] getSelectedObjects()
Returns the selected items on the list in an array of Objects.

See Also:
ItemSelectable
 o select
  public synchronized void select(int index)
Selects the item at the specified index.

Parameters:
index - the position of the item to select
See Also:
getSelectedItem, deselect, isIndexSelected
 o deselect
  public synchronized void deselect(int index)
Deselects the item at the specified index.

Parameters:
index - the position of the item to deselect
See Also:
select, getSelectedItem, isIndexSelected
 o isIndexSelected
  public boolean isIndexSelected(int index)
Returns true if the item at the specified index has been selected; false otherwise.

Parameters:
index - the item to be checked
See Also:
select, deselect
 o isSelected
  public boolean isSelected(int index)
Note: isSelected() is deprecated. As of JDK version 1.1, replaced by isIndexSelected(int).

 o getRows
  public int getRows()
Returns the number of visible lines in this list.

 o isMultipleMode
  public boolean isMultipleMode()
Returns true if this list allows multiple selections.

See Also:
setMultipleMode
 o allowsMultipleSelections
  public boolean allowsMultipleSelections()
Note: allowsMultipleSelections() is deprecated. As of JDK version 1.1, replaced by isMultipleMode().

 o setMultipleMode
  public synchronized void setMultipleMode(boolean b)
Sets whether this list should allow multiple selections or not.

Parameters:
v - the boolean to allow multiple selections
See Also:
isMultipleMode
 o setMultipleSelections
  public synchronized void setMultipleSelections(boolean b)
Note: setMultipleSelections() is deprecated. As of JDK version 1.1, replaced by setMultipleMode(boolean).

 o getVisibleIndex
  public int getVisibleIndex()
Gets the index of the item that was last made visible by the method makeVisible.

 o makeVisible
  public synchronized void makeVisible(int index)
Forces the item at the specified index to be visible.

Parameters:
index - the position of the item
See Also:
getVisibleIndex
 o getPreferredSize
  public Dimension getPreferredSize(int rows)
Returns the preferred dimensions needed for the list with the specified amount of rows.

Parameters:
rows - amount of rows in list.
 o preferredSize
  public Dimension preferredSize(int rows)
Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by getPreferredSize(int).

 o getPreferredSize
  public Dimension getPreferredSize()
Returns the preferred dimensions needed for the list.

Returns:
the preferred size with the specified number of rows if the row size is greater than 0.
Overrides:
getPreferredSize in class Component
 o preferredSize
  public Dimension preferredSize()
Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by getPreferredSize().

Overrides:
preferredSize in class Component
 o getMinimumSize
  public Dimension getMinimumSize(int rows)
Returns the minimum dimensions needed for the amount of rows in the list.

Parameters:
rows - minimum amount of rows in the list
 o minimumSize
  public Dimension minimumSize(int rows)
Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by getMinimumSize(int).

 o getMinimumSize
  public Dimension getMinimumSize()
Returns the minimum dimensions needed for the list.

Returns:
the preferred size with the specified number of rows if the row size is greater than zero.
Overrides:
getMinimumSize in class Component
 o minimumSize
  public Dimension minimumSize()
Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by getMinimumSize().

Overrides:
minimumSize in class Component
 o addItemListener
  public void addItemListener(ItemListener l)
Adds the specified item listener to recieve item events from this list.

Parameters:
l - the item listener
 o removeItemListener
  public void removeItemListener(ItemListener l)
Removes the specified item listener so it no longer receives item events from this list.

Parameters:
l - the item listener
 o addActionListener
  public void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this list. Action events occur when a list item is double-clicked.

Parameters:
l - the action listener
 o removeActionListener
  public void removeActionListener(ActionListener l)
Removes the specified action listener so it no longer receives action events from this list.

Parameters:
l - the action listener
 o processEvent
  protected void processEvent(AWTEvent e)
Processes events on this list. If the event is an ItemEvent, it invokes the processItemEvent method, else if the event is an ActionEvent, it invokes the processActionEvent method, else it invokes the superclass's processEvent.

Parameters:
e - the event
Overrides:
processEvent in class Component
 o processItemEvent
  protected void processItemEvent(ItemEvent e)
Processes item events occurring on this list by dispatching them to any registered ItemListener objects. NOTE: This method will not be called unless item events are enabled for this component; this happens when one of the following occurs: a) An ItemListener object is registered via addItemListener() b) Item events are enabled via enableEvents()

Parameters:
e - the item event
See Also:
enableEvents
 o processActionEvent
  protected void processActionEvent(ActionEvent e)
Processes action events occurring on this component by dispatching them to any registered ActionListener objects. NOTE: This method will not be called unless action events are enabled for this component; this happens when one of the following occurs: a) An ActionListener object is registered via addActionListener() b) Action events are enabled via enableEvents()

Parameters:
e - the action event
See Also:
enableEvents
 o paramString
  protected String paramString()
Returns the parameter String of this list.

Overrides:
paramString in class Component
 o delItems
  public synchronized void delItems(int start,
                                    int end)
Note: delItems() is 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.


All Packages  Class Hierarchy  This Package  Previous  Next  Index