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
		
TheList 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.
  -  Since:
  
-  JDK1.0
    
-  See Also:
    
-  ItemEvent, ItemListener, ActionEvent, ActionListener
   
  -   List() List()
-   Creates a new scrolling list.
  
-   List(int) List(int)
-   Creates a new scrolling list initialized with the specified 
 number of visible lines.
  
-   List(int, boolean) List(int, boolean)
-   Creates a new scrolling list initialized to display the specified 
 number of rows.
   
  -   add(String) add(String)
-   Adds the specified item to the end of scrolling list.
  
-   add(String, int) add(String, int)
-   Adds the specified item to the end of the scrolling list.
  
-   addActionListener(ActionListener) addActionListener(ActionListener)
-   Adds the specified action listener to receive action events from
 this list.
  
-   addItem(String) addItem(String)
-   
  
-   addItem(String, int) addItem(String, int)
-   
  
-   addItemListener(ItemListener) addItemListener(ItemListener)
-   Adds the specified item listener to receive item events from
 this list.
  
-   addNotify() addNotify()
-   Creates the peer for the list.
  
-   allowsMultipleSelections() allowsMultipleSelections()
-   
Deprecated.
  
-   clear() clear()
-   
Deprecated.
  
-   countItems() countItems()
-   
Deprecated.
  
-   delItem(int) delItem(int)
-   Removes the item at the specified position from this list.
  
-   delItems(int, int) delItems(int, int)
-   
Deprecated.
  
-   deselect(int) deselect(int)
-   Deselects the item at the specified index.
  
-   getItem(int) getItem(int)
-   Gets the item associated with the specified index.
  
-   getItemCount() getItemCount()
-   Gets the number of items in the list.
  
-   getItems() getItems()
-   Gets the items in the list.
  
-   getMinimumSize() getMinimumSize()
-   Determines the minimum size of this scrolling list.
  
-   getMinimumSize(int) getMinimumSize(int)
-   Gets the minumum dimensions for a list with the specified
 number of rows.
  
-   getPreferredSize() getPreferredSize()
-   Gets the preferred size of this scrolling list.
  
-   getPreferredSize(int) getPreferredSize(int)
-   Gets the preferred dimensions for a list with the specified
 number of rows.
  
-   getRows() getRows()
-   Get the number of visible lines in this list.
  
-   getSelectedIndex() getSelectedIndex()
-   Gets the index of the selected item on the list, 
 
  
-   getSelectedIndexes() getSelectedIndexes()
-   Gets the selected indexes on the list.
  
-   getSelectedItem() getSelectedItem()
-   Get the selected item on this scrolling list.
  
-   getSelectedItems() getSelectedItems()
-   Get the selected items on this scrolling list.
  
-   getSelectedObjects() getSelectedObjects()
-   Returns the selected items on the list in an array of Objects.
  
-   getVisibleIndex() getVisibleIndex()
-   Gets the index of the item that was last made visible by 
 the method makeVisible.
-   isIndexSelected(int) isIndexSelected(int)
-   Determines if the specified item in this scrolling list is 
 selected.
  
-   isMultipleMode() isMultipleMode()
-   Determines whether this list allows multiple selections.
  
-   isSelected(int) isSelected(int)
-   
Deprecated.
  
-   makeVisible(int) makeVisible(int)
-   Makes the item at the specified index visible.
  
-   minimumSize() minimumSize()
-   
Deprecated.
  
-   minimumSize(int) minimumSize(int)
-   
Deprecated.
  
-   paramString() paramString()
-   Returns the parameter string representing the state of this 
 scrolling list.
  
-   preferredSize() preferredSize()
-   
Deprecated.
  
-   preferredSize(int) preferredSize(int)
-   
Deprecated.
  
-   processActionEvent(ActionEvent) processActionEvent(ActionEvent)
-  
 Processes action events occurring on this component 
 by dispatching them to any registered 
 ActionListenerobjects.
-   processEvent(AWTEvent) processEvent(AWTEvent)
-   Processes events on this scrolling list.
  
-   processItemEvent(ItemEvent) processItemEvent(ItemEvent)
-  
 Processes item events occurring on this list by
 dispatching them to any registered 
 ItemListenerobjects.
-   remove(int) remove(int)
-   Remove the item at the specified position  
 from this scrolling list.
  
-   remove(String) remove(String)
-   Removes the first occurrence of an item from the list.
  
-   removeActionListener(ActionListener) removeActionListener(ActionListener)
-   Removes the specified action listener so that it no longer 
 receives action events from this list.
  
-   removeAll() removeAll()
-   Removes all items from this list.
  
-   removeItemListener(ItemListener) removeItemListener(ItemListener)
-   Removes the specified item listener so that it no longer 
 receives item events from this list.
  
-   removeNotify() removeNotify()
-   Removes the peer for this list.
  
-   replaceItem(String, int) replaceItem(String, int)
-   Replaces the item at the specified index in the scrolling list
 with the new string.
  
-   select(int) select(int)
-   Selects the item at the specified index in the scrolling list.
  
-   setMultipleMode(boolean) setMultipleMode(boolean)
-   Sets the flag that determines whether this list 
 allows multiple selections.
  
-   setMultipleSelections(boolean) setMultipleSelections(boolean)
-   
Deprecated.
   
 List
List
 public List()
  -  Creates a new scrolling list. Initially there are no visible 
 lines, and only one item can be selected from the list.
 
 List
List
 public List(int rows)
  -  Creates a new scrolling list initialized with the specified 
 number of visible lines. By default, multiple selections are
 not allowed.
   
- 
    -  Parameters:
    
-  rows - the number of items to show.
  
 
 List
List
 public List(int rows,
             boolean multipleMode)
  -  Creates a new scrolling list initialized to display the specified 
 number of rows. If the value of multipleModeistrue, then the user can select multiple items from  
 the list. If it isfalse, only one item at a time 
 can be selected.
   
- 
    -  Parameters:
    
-  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.
 
   
 addNotify
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
  
 
 removeNotify
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
  
 
 getItemCount
getItemCount
 public int getItemCount()
  -  Gets the number of items in the list.
   
- 
    -  Returns:
    
-  the number of items in the list.
    
-  See Also:
    
-  getItem
  
 
 countItems
countItems
 public int countItems()
-  Note: countItems() is deprecated.
As of JDK version 1.1,
 replaced by getItemCount().
 
 getItem
getItem
 public String getItem(int index)
  -  Gets the item associated with the specified index.
   
- 
    -  Parameters:
    
-  index - the position of the item.
    
-  Returns:
    
-  an item that is associated with
                    the specified index.
    
-  See Also:
    
-  getItemCount
  
 
 getItems
getItems
 public synchronized String[] getItems()
  -  Gets the items in the list.
   
- 
    -  Returns:
    
-  a string array containing items of the list.
    
-  See Also:
    
-  select, deselect, isIndexSelected
  
 
 add
add
 public void add(String item)
  -  Adds the specified item to the end of scrolling list.
   
- 
    -  Parameters:
    
-  item - the item to be added.
  
 
 addItem
addItem
 public void addItem(String item)
 add
add
 public synchronized void add(String item,
                              int index)
  -  Adds the specified item to the end of the scrolling list.
 The index is zero-based. If value of the index is 
 -1then the item is added to the end. 
 If value of the index is greater than the number of 
 items in the list, the item is added at the end.
   
- 
    -  Parameters:
    
-  item - the item to be added.
    -  index - the position at which to add the item.
  
 
 addItem
addItem
 public synchronized void addItem(String item,
                                  int index)
 replaceItem
replaceItem
 public synchronized void replaceItem(String newValue,
                                      int index)
  -  Replaces the item at the specified index in the scrolling list
 with the new string.
   
- 
    -  Parameters:
    
-  newValue - a new string to replace an existing item.
    -  index - the position of the item to replace.
  
 
 removeAll
removeAll
 public synchronized void removeAll()
  -  Removes all items from this list.
   
- 
    -  See Also:
    
-  remove, delItems
  
 
 clear
clear
 public synchronized void clear()
-  Note: clear() is deprecated.
As of JDK version 1.1,
 replaced by removeAll().
 
 remove
remove
 public synchronized void remove(String item)
  -  Removes the first occurrence of an item from the list.
   
- 
    -  Parameters:
    
-  item - the item to remove from the list.
    
-  Throws: IllegalArgumentException
    
-  if the item doesn't exist in the list.
  
 
 remove
remove
 public synchronized void remove(int position)
  -  Remove the item at the specified position  
 from this scrolling list.
   
- 
    -  Parameters:
    
-  position - the index of the item to delete.
    
-  See Also:
    
-  add
  
 
 delItem
delItem
 public synchronized void delItem(int position)
  -  Removes the item at the specified position from this list.
 
 getSelectedIndex
getSelectedIndex
 public synchronized int getSelectedIndex()
  -  Gets the index of the selected item on the list,
   
- 
    -  Returns:
    
-  the index of the selected item, or
                     -1if no item is selected,
                     or if more that one item is selected.
-  See Also:
    
-  select, deselect, isIndexSelected
  
 
 getSelectedIndexes
getSelectedIndexes
 public synchronized int[] getSelectedIndexes()
  -  Gets the selected indexes on the list.
   
- 
    -  Returns:
    
-  an array of the selected indexes
                            of this scrolling list.
    
-  See Also:
    
-  select, deselect, isIndexSelected
  
 
 getSelectedItem
getSelectedItem
 public synchronized String getSelectedItem()
  -  Get the selected item on this scrolling list.
   
- 
    -  Returns:
    
-  the selected item on the list,
                     or null if no item is selected.
    
-  See Also:
    
-  select, deselect, isIndexSelected
  
 
 getSelectedItems
getSelectedItems
 public synchronized String[] getSelectedItems()
  -  Get the selected items on this scrolling list.
   
- 
    -  Returns:
    
-  an array of the selected items
                            on this scrolling list.
    
-  See Also:
    
-  select, deselect, isIndexSelected
  
 
 getSelectedObjects
getSelectedObjects
 public Object[] getSelectedObjects()
  -  Returns the selected items on the list in an array of Objects.
   
- 
    -  See Also:
    
-  ItemSelectable
  
 
 select
select
 public void select(int index)
  -  Selects the item at the specified index in the scrolling list.
   
- 
    -  Parameters:
    
-  index - the position of the item to select.
    
-  See Also:
    
-  getSelectedItem, deselect, isIndexSelected
  
 
 deselect
deselect
 public synchronized void deselect(int index)
  -  Deselects the item at the specified index.
 
 If the item at the specified index is not selected, or if the 
 index is out of range, then the operation is ignored.
 
   
- 
    -  Parameters:
    
-  index - the position of the item to deselect.
    
-  See Also:
    
-  select, getSelectedItem, isIndexSelected
  
 
 isIndexSelected
isIndexSelected
 public boolean isIndexSelected(int index)
  -  Determines if the specified item in this scrolling list is 
 selected.
   
- 
    -  Parameters:
    
-  index - the item to be checked.
    
-  Returns:
    
-  trueif the specified item has been
                       selected;falseotherwise.
-  See Also:
    
-  select, deselect
  
 
 isSelected
isSelected
 public boolean isSelected(int index)
-  Note: isSelected() is deprecated.
As of JDK version 1.1,
 replaced by isIndexSelected(int).
 
 getRows
getRows
 public int getRows()
  -  Get the number of visible lines in this list.
   
- 
    -  Returns:
    
-  the number of visible lines in this scrolling list.
  
 
 isMultipleMode
isMultipleMode
 public boolean isMultipleMode()
  -  Determines whether this list allows multiple selections.
   
- 
    -  Returns:
    
-  trueif this list allows multiple
                 selections; otherwise,false.
-  See Also:
    
-  setMultipleMode
  
 
 allowsMultipleSelections
allowsMultipleSelections
 public boolean allowsMultipleSelections()
-  Note: allowsMultipleSelections() is deprecated.
As of JDK version 1.1,
 replaced by isMultipleMode().
 
 setMultipleMode
setMultipleMode
 public synchronized void setMultipleMode(boolean b)
  -  Sets the flag that determines whether this list 
 allows multiple selections.
   
- 
    -  Parameters:
    
-  b - if truethen multiple selections
                      are allowed; otherwise, only one item from
                      the list can be selected at once.
-  See Also:
    
-  isMultipleMode
  
 
 setMultipleSelections
setMultipleSelections
 public synchronized void setMultipleSelections(boolean b)
-  Note: setMultipleSelections() is deprecated.
As of JDK version 1.1,
 replaced by setMultipleMode(boolean).
 
 getVisibleIndex
getVisibleIndex
 public int getVisibleIndex()
  -  Gets the index of the item that was last made visible by 
 the method makeVisible.
   
- 
    -  Returns:
    
-  the index of the item that was last made visible.
    
-  See Also:
    
-  makeVisible
  
 
 makeVisible
makeVisible
 public synchronized void makeVisible(int index)
  -  Makes the item at the specified index visible.
   
- 
    -  Parameters:
    
-  index - the position of the item.
    
-  See Also:
    
-  getVisibleIndex
  
 
 getPreferredSize
getPreferredSize
 public Dimension getPreferredSize(int rows)
  -  Gets the preferred dimensions for a list with the specified
 number of rows.
   
- 
    -  Parameters:
    
-  rows - number of rows in the list.
    
-  Returns:
    
-  the preferred dimensions for displaying this scrolling list.
    
-  See Also:
    
-  getPreferredSize
  
 
 preferredSize
preferredSize
 public Dimension preferredSize(int rows)
-  Note: preferredSize() is deprecated.
As of JDK version 1.1,
 replaced by getPreferredSize(int).
 
 getPreferredSize
getPreferredSize
 public Dimension getPreferredSize()
  -  Gets the preferred size of this scrolling list.
   
- 
    -  Returns:
    
-  the preferred dimensions for displaying this scrolling list.
    
-  Overrides:
    
-  getPreferredSize in class Component
    
-  See Also:
    
-  getPreferredSize
  
 
 preferredSize
preferredSize
 public Dimension preferredSize()
-  Note: preferredSize() is deprecated.
As of JDK version 1.1,
 replaced by getPreferredSize().
   
- 
    -  Overrides:
    
-  preferredSize in class Component
  
 
 getMinimumSize
getMinimumSize
 public Dimension getMinimumSize(int rows)
  -  Gets the minumum dimensions for a list with the specified
 number of rows.
   
- 
    -  Parameters:
    
-  rows - number of rows in the list.
    
-  Returns:
    
-  the minimum dimensions for displaying this scrolling list.
    
-  See Also:
    
-  getMinimumSize
  
 
 minimumSize
minimumSize
 public Dimension minimumSize(int rows)
-  Note: minimumSize() is deprecated.
As of JDK version 1.1,
 replaced by getMinimumSize(int).
 
 getMinimumSize
getMinimumSize
 public Dimension getMinimumSize()
  -  Determines the minimum size of this scrolling list.
   
- 
    -  Returns:
    
-  the minimum dimensions needed
                        to display this scrolling list.
    
-  Overrides:
    
-  getMinimumSize in class Component
    
-  See Also:
    
-  getMinimumSize
  
 
 minimumSize
minimumSize
 public Dimension minimumSize()
-  Note: minimumSize() is deprecated.
As of JDK version 1.1,
 replaced by getMinimumSize().
   
- 
    -  Overrides:
    
-  minimumSize in class Component
  
 
 addItemListener
addItemListener
 public synchronized void addItemListener(ItemListener l)
  -  Adds the specified item listener to receive item events from
 this list.
   
- 
    -  Parameters:
    
-  l - the item listener.
    
-  See Also:
    
-  ItemEvent, ItemListener, removeItemListener
  
 
 removeItemListener
removeItemListener
 public synchronized void removeItemListener(ItemListener l)
  -  Removes the specified item listener so that it no longer 
 receives item events from this list.
   
- 
    -  Parameters:
    
-  l - the item listener.
    
-  See Also:
    
-  ItemEvent, ItemListener, addItemListener
  
 
 addActionListener
addActionListener
 public synchronized void addActionListener(ActionListener l)
  -  Adds the specified action listener to receive action events from
 this list. Action events occur when a user double-clicks
 on a list item.
   
- 
    -  Parameters:
    
-  l - the action listener.
    
-  See Also:
    
-  ActionEvent, ActionListener, removeActionListener
  
 
 removeActionListener
removeActionListener
 public synchronized void removeActionListener(ActionListener l)
  -  Removes the specified action listener so that it no longer 
 receives action events from this list. Action events 
 occur when a user double-clicks on a list item.
   
- 
    -  Parameters:
    
-  l - the action listener.
    
-  See Also:
    
-  ActionEvent, ActionListener, addActionListener
  
 
 processEvent
processEvent
 protected void processEvent(AWTEvent e)
  -  Processes events on this scrolling list. If an event is 
 an instance of ItemEvent, it invokes theprocessItemEventmethod. Else, if the 
 event is an instance ofActionEvent, 
 it invokesprocessActionEvent.
 If the event is not an item event or an action event,
 it invokesprocessEventon the superclass.
   
- 
    -  Parameters:
    
-  e - the event.
    
-  Overrides:
    
-  processEvent in class Component
    
-  See Also:
    
-  ActionEvent, ItemEvent, processActionEvent, processItemEvent
  
 
 processItemEvent
processItemEvent
 protected void processItemEvent(ItemEvent e)
  -  Processes item events occurring on this list by
 dispatching them to any registered 
 ItemListenerobjects.
 This method is not called unless item events are 
 enabled for this component. Item events are enabled 
 when one of the following occurs:
  
 - An ItemListenerobject is registered 
 viaaddItemListener.
- Item events are enabled via enableEvents.
 
   
- 
    -  Parameters:
    
-  e - the item event.
    
-  See Also:
    
-  ItemEvent, ItemListener, addItemListener, enableEvents
  
 
 processActionEvent
processActionEvent
 protected void processActionEvent(ActionEvent e)
  -  Processes action events occurring on this component 
 by dispatching them to any registered 
 ActionListenerobjects.
 This method is not called unless action events are 
 enabled for this component. Action events are enabled 
 when one of the following occurs:
  
 - An ActionListenerobject is registered 
 viaaddActionListener.
- Action events are enabled via enableEvents.
 
   
- 
    -  Parameters:
    
-  e - the action event.
    
-  See Also:
    
-  ActionEvent, ActionListener, addActionListener, enableEvents
  
 
 paramString
paramString
 protected String paramString()
  -  Returns the parameter string representing the state of this 
 scrolling list. This string is useful for debugging.
   
- 
    -  Returns:
    
-  the parameter string of this scrolling list.
    
-  Overrides:
    
-  paramString in class Component
  
 
 delItems
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
Submit a bug or feature