java.awt
Class Choice
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Choice
All Implemented Interfaces:
ItemSelectable, Serializable, ImageObserver, MenuContainer, Serializable
This class implements a drop down choice list.
Author:- Aaron M. Renn (arenn@urbanophile.com)
Choice
public Choice()
Initializes a new instance of Choice
.
Throws:
add
public synchronized void add(java.lang.String item)
Adds the specified item to this choice box.
Since:Parameters:
Throws:
addItem
public synchronized void addItem(java.lang.String item)
Adds the specified item to this choice box.
This method is oboslete since Java 2 platform 1.1. Please use @see add
instead.
Parameters:
Throws:
addItemListener
public synchronized void addItemListener(java.awt.event.ItemListener listener)
Adds the specified listener to the list of registered listeners for
this object.
Parameters:
addNotify
public void addNotify()
Creates the native peer for this object.
countItems
public int countItems()
Returns the number of items in the list.
Returns:
- The number of items in the list.
getItem
public String getItem(int index)
Returns the item at the specified index in the list.
Parameters:
Throws:
getItemCount
public int getItemCount()
Returns the number of items in the list.
Returns:
- The number of items in the list.
getItemListeners
public ItemListener[] getItemListeners()
Returns all registered item listeners.
Since:
getListeners
public EventListener[] getListeners(java.lang.Class listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this Choice. FooListeners are registered using the addFooListener
method.
Since:Parameters:
Throws:
ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.
getSelectedIndex
public int getSelectedIndex()
Returns the index of the selected item.
Returns:
- The index of the selected item.
getSelectedItem
public synchronized String getSelectedItem()
Returns the currently selected item, or null if no item is
selected.
Returns:
- The currently selected item.
getSelectedObjects
public synchronized Object[] getSelectedObjects()
Returns an array with one row containing the selected item.
Returns:
- An array containing the selected item.
insert
public synchronized void insert(java.lang.String item, int index)
Inserts an item into this Choice. Existing items are shifted
upwards. If the new item is the only item, then it is selected.
If the currently selected item is shifted, then the first item is
selected. If the currently selected item is not shifted, then it
remains selected.
Parameters:
Throws:
paramString
protected String paramString()
Returns a debugging string for this object.
Returns:
- A debugging string for this object.
processEvent
protected void processEvent(java.awt.AWTEvent event)
Processes this event by invoking processItemEvent()
if the
event is an instance of ItemEvent
, otherwise the event
is passed to the superclass.
Parameters:
processItemEvent
protected void processItemEvent(java.awt.event.ItemEvent event)
Processes item event by dispatching to any registered listeners.
Parameters:
remove
public synchronized void remove(int index)
Removes the item at the specified index from the choice box.
Parameters:
Throws:
remove
public synchronized void remove(java.lang.String item)
Removes the specified item from the choice box.
Parameters:
Throws:
removeAll
public synchronized void removeAll()
Removes all of the objects from this choice box.
removeItemListener
public synchronized void removeItemListener(java.awt.event.ItemListener listener)
Removes the specified listener from the list of registered listeners for
this object.
Parameters:
select
public synchronized void select(int index)
Forces the item at the specified index to be selected.
Parameters:
Throws:
select
public synchronized void select(java.lang.String item)
Forces the named item to be selected.
Parameters:
Throws: