Class java.awt.List
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
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, 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 addItem(String)
Adds the specified item to the end of scrolling list.
 o addItem(String, int)
Adds the specified item to the end of scrolling list.
 o addNotify()
Creates the peer for the list.
 o allowsMultipleSelections()
Returns true if this list allows multiple selections.
 o clear()
Clears the list.
 o countItems()
Returns the number of items in the list.
 o delItem(int)
Delete an item from the list.
 o delItems(int, int)
Delete multiple items from the list.
 o deselect(int)
Deselects the item at the specified index.
 o getItem(int)
Gets the item associated with the specified index.
 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.
 o getVisibleIndex()
Gets the index of the item that was last made visible by the method makeVisible.
 o isSelected(int)
Returns true if the item at the specified index has been selected; false otherwise.
 o makeVisible(int)
Forces the item at the specified index to be visible.
 o minimumSize()
Returns the minimum dimensions needed for the list.
 o minimumSize(int)
Returns the minimum dimensions needed for the amount of rows in the list.
 o paramString()
Returns the parameter String of this list.
 o preferredSize()
Returns the preferred dimensions needed for the list.
 o preferredSize(int)
Returns the preferred dimensions needed for the list with the specified amount of rows.
 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 setMultipleSelections(boolean)
Sets whether this list should allow multiple selections or not.

Constructors

 o List
  public List()
Creates a new scrolling list initialized with no visible Lines or multiple selections.
 o List
  public List(int rows,
              boolean multipleSelections)
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.
multipleSelections - if true then multiple selections are allowed.

Methods

 o addNotify
  public synchronized 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 synchronized 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 countItems
  public int countItems()
Returns the number of items in the list.
See Also:
getItem
 o getItem
  public String getItem(int index)
Gets the item associated with the specified index.
Parameters:
index - the position of the item
See Also:
countItems
 o addItem
  public synchronized void addItem(String item)
Adds the specified item to the end of scrolling list.
Parameters:
item - the item to be added
 o addItem
  public synchronized void addItem(String item,
                                   int index)
Adds the specified item to the end of scrolling list.
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 clear
  public synchronized void clear()
Clears the list.
See Also:
delItem, delItems
 o delItem
  public synchronized void delItem(int position)
Delete an item from the list.
 o delItems
  public synchronized void delItems(int start,
                                    int end)
Delete multiple items 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, isSelected
 o getSelectedIndexes
  public synchronized int[] getSelectedIndexes()
Returns the selected indexes on the list.
See Also:
select, deselect, isSelected
 o getSelectedItem
  public synchronized String getSelectedItem()
Returns the selected item on the list or null if no item is selected.
See Also:
select, deselect, isSelected
 o getSelectedItems
  public synchronized String[] getSelectedItems()
Returns the selected items on the list.
See Also:
select, deselect, isSelected
 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, isSelected
 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, isSelected
 o isSelected
  public synchronized boolean isSelected(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, isSelected
 o getRows
  public int getRows()
Returns the number of visible lines in this list.
 o allowsMultipleSelections
  public boolean allowsMultipleSelections()
Returns true if this list allows multiple selections.
See Also:
setMultipleSelections
 o setMultipleSelections
  public void setMultipleSelections(boolean v)
Sets whether this list should allow multiple selections or not.
Parameters:
v - the boolean to allow multiple selections
See Also:
allowsMultipleSelections
 o getVisibleIndex
  public int getVisibleIndex()
Gets the index of the item that was last made visible by the method makeVisible.
 o makeVisible
  public 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 preferredSize
  public Dimension preferredSize(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()
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:
preferredSize in class Component
 o minimumSize
  public Dimension minimumSize(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()
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:
minimumSize in class Component
 o paramString
  protected String paramString()
Returns the parameter String of this list.
Overrides:
paramString in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index