Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class List

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

All Implemented Interfaces:

ItemSelectable, Accessible, ImageObserver, MenuContainer, Serializable


public class List

extends Component

implements ItemSelectable, Accessible

Class that implements a listbox widget

Author:

Constructor Summary

List()

Initializes a new instance of List with no visible lines and multi-select disabled.
List(int rows)

Initializes a new instance of List with the specified number of visible lines and multi-select disabled.
List(int rows, boolean multipleMode)

Initializes a new instance of List with the specified number of lines and the specified multi-select setting.

Method Summary

voidadd(java.lang.String item)

This method adds the specified item to the end of the list.
voidadd(java.lang.String item, int index)

Adds the specified item to the specified location in the list.
synchronized voidaddActionListener(java.awt.event.ActionListener listener)

Adds the specified ActionListener to the list of registered listeners for this object.
voidaddItem(java.lang.String item)

This method adds the specified item to the end of the list.
voidaddItem(java.lang.String item, int index)

Adds the specified item to the specified location in the list.
synchronized voidaddItemListener(java.awt.event.ItemListener listener)

Adds the specified ItemListener to the list of registered listeners for this object.
voidaddNotify()

Notifies this object to create its native peer.
booleanallowsMultipleSelections()

Tests whether or not multi-select mode is enabled.
voidclear()

Deletes all of the items from the list.
intcountItems()

Returns the number of items in this list.
voiddelItem(int index)

Deletes the item at the specified index.
synchronized voiddelItems(int start, int end)

Deletes all items in the specified index range.
synchronized voiddeselect(int index)

Makes the item at the specified index not selected.
java.awt.event.ActionListener[]getActionListeners()

Returns all action listeners registered to this object.
java.lang.StringgetItem(int index)

Returns the item at the specified index.
intgetItemCount()

Returns the number of items in this list.
java.awt.event.ItemListener[]getItemListeners()

Returns all action listeners registered to this object.
synchronized java.lang.String[]getItems()

Returns the complete list of items.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this List.
java.awt.DimensiongetMinimumSize()

Returns the minimum size of this component.
java.awt.DimensiongetMinimumSize(int rows)

Returns the minimum size of this component assuming it had the specified number of rows.
java.awt.DimensiongetPreferredSize()

Returns the preferred size of this component.
java.awt.DimensiongetPreferredSize(int rows)

Returns the preferred size of this component assuming it had the specified number of rows.
intgetRows()

Returns the number of visible rows in the list.
synchronized intgetSelectedIndex()

Returns the index of the currently selected item.
synchronized int[]getSelectedIndexes()

Returns an array containing the indexes of the rows that are currently selected.
synchronized java.lang.StringgetSelectedItem()

Returns the item that is currently selected, or null if there is no item selected.
synchronized java.lang.String[]getSelectedItems()

Returns the list of items that are currently selected in this list.
synchronized java.lang.Object[]getSelectedObjects()

Returns the list of items that are currently selected in this list as an array of type Object[] instead of String[].
intgetVisibleIndex()

Returns the index of the last item that was made visible via the makeVisible() method.
booleanisIndexSelected(int index)

Tests whether or not the specified index is selected.
booleanisMultipleMode()

Tests whether or not multi-select mode is enabled.
booleanisSelected(int index)

Tests whether or not the specified index is selected.
synchronized voidmakeVisible(int index)

This method ensures that the item at the specified index is visible.
java.awt.DimensionminimumSize()

Returns the minimum size of this component.
java.awt.DimensionminimumSize(int rows)

Returns the minimum size of this component assuming it had the specified number of rows.
java.lang.StringparamString()

Returns a debugging string for this object.
java.awt.DimensionpreferredSize()

Returns the preferred size of this component.
java.awt.DimensionpreferredSize(int rows)

Returns the preferred size of this component assuming it had the specified number of rows.
voidprocessActionEvent(java.awt.event.ActionEvent event)

This method processes the specified event by dispatching it to any registered listeners.
voidprocessEvent(java.awt.AWTEvent event)

Processes the specified event for this object.
voidprocessItemEvent(java.awt.event.ItemEvent event)

This method processes the specified event by dispatching it to any registered listeners.
voidremove(int index)

Deletes the item at the specified index.
synchronized voidremove(java.lang.String item)

Deletes the first occurrence of the specified item from the list.
synchronized voidremoveActionListener(java.awt.event.ActionListener listener)

Removes the specified ActionListener from the list of registers listeners for this object.
synchronized voidremoveAll()

Deletes all of the items from the list.
synchronized voidremoveItemListener(java.awt.event.ItemListener listener)

Removes the specified ItemListener from the list of registers listeners for this object.
voidremoveNotify()

Notifies this object to destroy its native peer.
synchronized voidreplaceItem(java.lang.String item, int index)

Replaces the item at the specified index with the specified item.
synchronized voidselect(int index)

Makes the item at the specified index selected.
voidsetMultipleMode(boolean multipleMode)

This method enables or disables multiple selection mode for this list.
voidsetMultipleSelections(boolean multipleMode)

This method enables or disables multiple selection mode for this list.

Constructor Details

List

public List()

Initializes a new instance of List with no visible lines and multi-select disabled.

Throws:


List

public List(int rows)

Initializes a new instance of List with the specified number of visible lines and multi-select disabled.

Parameters:

Throws:


List

public List(int rows, boolean multipleMode)

Initializes a new instance of List with the specified number of lines and the specified multi-select setting.

Parameters:

Throws:


Method Details

add

public void add(java.lang.String item)

This method adds the specified item to the end of the list.

Parameters:


add

public void add(java.lang.String item, int index)

Adds the specified item to the specified location in the list. If the desired index is -1 or greater than the number of rows in the list, then the item is added to the end.

Parameters:


addActionListener

public synchronized void addActionListener(java.awt.event.ActionListener listener)

Adds the specified ActionListener to the list of registered listeners for this object.

Parameters:


addItem

public void addItem(java.lang.String item)

This method adds the specified item to the end of the list.

Parameters:


addItem

public void addItem(java.lang.String item, int index)

Adds the specified item to the specified location in the list. If the desired index is -1 or greater than the number of rows in the list, then the item is added to the end.

Parameters:


addItemListener

public synchronized void addItemListener(java.awt.event.ItemListener listener)

Adds the specified ItemListener to the list of registered listeners for this object.

Parameters:


addNotify

public void addNotify()

Notifies this object to create its native peer.


allowsMultipleSelections

public boolean allowsMultipleSelections()

Tests whether or not multi-select mode is enabled.

Returns:


clear

public void clear()

Deletes all of the items from the list.


countItems

public int countItems()

Returns the number of items in this list.

Returns:


delItem

public void delItem(int index)

Deletes the item at the specified index.

Parameters:

Throws:


delItems

public synchronized void delItems(int start, int end)

Deletes all items in the specified index range.

Parameters:

Throws:


deselect

public synchronized void deselect(int index)

Makes the item at the specified index not selected.

Parameters:


getActionListeners

public ActionListener[] getActionListeners()

Returns all action listeners registered to this object.


getItem

public String getItem(int index)

Returns the item at the specified index.

Parameters:

Throws:


getItemCount

public int getItemCount()

Returns the number of items in this list.

Returns:


getItemListeners

public ItemListener[] getItemListeners()

Returns all action listeners registered to this object.


getItems

public synchronized String[] getItems()

Returns the complete list of items.

Returns:


getListeners

public EventListener[] getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this List. FooListeners are registered using the addFooListener method.

Parameters:

Throws:


getMinimumSize

public Dimension getMinimumSize()

Returns the minimum size of this component.

Returns:


getMinimumSize

public Dimension getMinimumSize(int rows)

Returns the minimum size of this component assuming it had the specified number of rows.

Parameters:

Returns:


getPreferredSize

public Dimension getPreferredSize()

Returns the preferred size of this component.

Returns:


getPreferredSize

public Dimension getPreferredSize(int rows)

Returns the preferred size of this component assuming it had the specified number of rows.

Parameters:

Returns:


getRows

public int getRows()

Returns the number of visible rows in the list.

Returns:


getSelectedIndex

public synchronized int getSelectedIndex()

Returns the index of the currently selected item. -1 will be returned if there are no selected rows or if there are multiple selected rows.

Returns:


getSelectedIndexes

public synchronized int[] getSelectedIndexes()

Returns an array containing the indexes of the rows that are currently selected.

Returns:


getSelectedItem

public synchronized String getSelectedItem()

Returns the item that is currently selected, or null if there is no item selected. FIXME: What happens if multiple items selected?

Returns:


getSelectedItems

public synchronized String[] getSelectedItems()

Returns the list of items that are currently selected in this list.

Returns:


getSelectedObjects

public synchronized Object[] getSelectedObjects()

Returns the list of items that are currently selected in this list as an array of type Object[] instead of String[].

Returns:


getVisibleIndex

public int getVisibleIndex()

Returns the index of the last item that was made visible via the makeVisible() method.

Returns:


isIndexSelected

public boolean isIndexSelected(int index)

Tests whether or not the specified index is selected.

Parameters:

Returns:


isMultipleMode

public boolean isMultipleMode()

Tests whether or not multi-select mode is enabled.

Returns:


isSelected

public boolean isSelected(int index)

Tests whether or not the specified index is selected.

Parameters:

Returns:


makeVisible

public synchronized void makeVisible(int index)

This method ensures that the item at the specified index is visible.

Parameters:

Throws:


minimumSize

public Dimension minimumSize()

Returns the minimum size of this component.

Returns:


minimumSize

public Dimension minimumSize(int rows)

Returns the minimum size of this component assuming it had the specified number of rows.

Parameters:

Returns:


paramString

protected String paramString()

Returns a debugging string for this object.

Returns:


preferredSize

public Dimension preferredSize()

Returns the preferred size of this component.

Returns:


preferredSize

public Dimension preferredSize(int rows)

Returns the preferred size of this component assuming it had the specified number of rows.

Parameters:

Returns:


processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)

This method processes the specified event by dispatching it to any registered listeners. Note that this method will only get called if action events are enabled. This will happen automatically if any listeners are added, or it can be done "manually" by calling the enableEvents() method.

Parameters:


processEvent

protected void processEvent(java.awt.AWTEvent event)

Processes the specified event for this object. If the event is an instance of ActionEvent then the processActionEvent() method is called. Similarly, if the even is an instance of ItemEvent then the processItemEvent() method is called. Otherwise the superclass method is called to process this event.

Parameters:


processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent event)

This method processes the specified event by dispatching it to any registered listeners. Note that this method will only get called if item events are enabled. This will happen automatically if any listeners are added, or it can be done "manually" by calling the enableEvents() method.

Parameters:


remove

public void remove(int index)

Deletes the item at the specified index.

Parameters:

Throws:


remove

public synchronized void remove(java.lang.String item)

Deletes the first occurrence of the specified item from the list.

Parameters:

Throws:


removeActionListener

public synchronized void removeActionListener(java.awt.event.ActionListener listener)

Removes the specified ActionListener from the list of registers listeners for this object.

Parameters:


removeAll

public synchronized void removeAll()

Deletes all of the items from the list.


removeItemListener

public synchronized void removeItemListener(java.awt.event.ItemListener listener)

Removes the specified ItemListener from the list of registers listeners for this object.

Parameters:


removeNotify

public void removeNotify()

Notifies this object to destroy its native peer.


replaceItem

public synchronized void replaceItem(java.lang.String item, int index)

Replaces the item at the specified index with the specified item.

Parameters:

Throws:


select

public synchronized void select(int index)

Makes the item at the specified index selected.

Parameters:


setMultipleMode

public void setMultipleMode(boolean multipleMode)

This method enables or disables multiple selection mode for this list.

Parameters:


setMultipleSelections

public void setMultipleSelections(boolean multipleMode)

This method enables or disables multiple selection mode for this list.

Parameters: