java.awt
Class List
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.List
All Implemented Interfaces:
ItemSelectable, Accessible, ImageObserver, MenuContainer, Serializable
Class that implements a listbox widget
Author:- Aaron M. Renn (arenn@urbanophile.com)
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:
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:
true
if multi-select mode is enabled,
false
otherwise.
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:
- The number of items in this list.
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:
- The number of items in this list.
getItemListeners
public ItemListener[] getItemListeners()
Returns all action listeners registered to this object.
getItems
public synchronized String[] getItems()
Returns the complete list of items.
Returns:
- The complete list of items in the list.
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:
ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.
getMinimumSize
public Dimension getMinimumSize()
Returns the minimum size of this component.
Returns:
- The minimum size of this component.
getMinimumSize
public Dimension getMinimumSize(int rows)
Returns the minimum size of this component assuming it had the specified
number of rows.
Parameters:
Returns:
- The minimum size of this component.
getPreferredSize
public Dimension getPreferredSize()
Returns the preferred size of this component.
Returns:
- The preferred size of this component.
getPreferredSize
public Dimension getPreferredSize(int rows)
Returns the preferred size of this component assuming it had the specified
number of rows.
Parameters:
Returns:
- The preferred size of this component.
getRows
public int getRows()
Returns the number of visible rows in the list.
Returns:
- The number of visible rows in the list.
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:
- The index of the selected row.
getSelectedIndexes
public synchronized int[] getSelectedIndexes()
Returns an array containing the indexes of the rows that are
currently selected.
Returns:
- A list of indexes of selected rows.
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:
- The selected item, or
null
if there is no
selected item.
getSelectedItems
public synchronized String[] getSelectedItems()
Returns the list of items that are currently selected in this list.
Returns:
- The list of currently selected items.
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:
- The list of currently selected items.
getVisibleIndex
public int getVisibleIndex()
Returns the index of the last item that was made visible via the
makeVisible()
method.
Returns:
- The index of the last item made visible via the
makeVisible()
method.
isIndexSelected
public boolean isIndexSelected(int index)
Tests whether or not the specified index is selected.
Parameters:
Returns:
true
if the index is selected, false
otherwise.
isMultipleMode
public boolean isMultipleMode()
Tests whether or not multi-select mode is enabled.
Returns:
true
if multi-select mode is enabled,
false
otherwise.
isSelected
public boolean isSelected(int index)
Tests whether or not the specified index is selected.
Parameters:
Returns:
true
if the index is selected, false
otherwise.
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:
- The minimum size of this component.
minimumSize
public Dimension minimumSize(int rows)
Returns the minimum size of this component assuming it had the specified
number of rows.
Parameters:
Returns:
- The minimum size of this component.
paramString
protected String paramString()
Returns a debugging string for this object.
Returns:
- A debugging string for this object.
preferredSize
public Dimension preferredSize()
Returns the preferred size of this component.
Returns:
- The preferred size of this component.
preferredSize
public Dimension preferredSize(int rows)
Returns the preferred size of this component assuming it had the specified
number of rows.
Parameters:
Returns:
- The preferred size of this component.
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: