java.awt
public class Choice extends Component implements ItemSelectable, Serializable, Accessible
Nested Class Summary | |
---|---|
protected class | Choice.AccessibleAWTChoice
This class provides accessibility support for the
combo box.
|
Constructor Summary | |
---|---|
Choice()
Initializes a new instance of Choice .
|
Method Summary | |
---|---|
void | add(String item)
Adds the specified item to this choice box.
|
void | addItem(String item)
Adds the specified item to this choice box.
|
void | addItemListener(ItemListener listener)
Adds the specified listener to the list of registered listeners for
this object.
|
void | addNotify()
Creates the native peer for this object. |
int | countItems()
Returns the number of items in the list.
|
AccessibleContext | getAccessibleContext()
Gets the AccessibleContext associated with this Choice .
|
String | getItem(int index)
Returns the item at the specified index in the list.
|
int | getItemCount()
Returns the number of items in the list.
|
ItemListener[] | getItemListeners()
Returns all registered item listeners.
|
<T extends EventListener> T[] | getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this Choice. |
int | getSelectedIndex()
Returns the index of the selected item.
|
String | getSelectedItem()
Returns the currently selected item, or null if no item is
selected.
|
Object[] | getSelectedObjects()
Returns an array with one row containing the selected item.
|
void | insert(String item, int index) Inserts an item into this Choice. |
protected String | paramString()
Returns a debugging string for this object.
|
protected void | processEvent(AWTEvent event)
Processes this event by invoking processItemEvent() if the
event is an instance of ItemEvent , otherwise the event
is passed to the superclass.
|
protected void | processItemEvent(ItemEvent event)
Processes item event by dispatching to any registered listeners.
|
void | remove(String item)
Removes the specified item from the choice box.
|
void | remove(int index)
Removes the item at the specified index from the choice box.
|
void | removeAll()
Removes all of the objects from this choice box. |
void | removeItemListener(ItemListener listener)
Removes the specified listener from the list of registered listeners for
this object.
|
void | select(int index)
Forces the item at the specified index to be selected.
|
void | select(String item)
Forces the named item to be selected.
|
Choice
.
Throws: HeadlessException If GraphicsEnvironment.isHeadless() returns true
Parameters: item The item to add.
Throws: NullPointerException If the item's value is null
Since: 1.1
Parameters: item The item to add.
Throws: NullPointerException If the item's value is equal to null
Parameters: listener The listener to add.
Deprecated: This method is deprecated in favor of getItemCount
.
Returns: The number of items in the list.
Choice
.
The context is created, if necessary.
Returns: the associated context
Parameters: index The index into the list to return the item from.
Throws: ArrayIndexOutOfBoundsException If the index is invalid.
Returns: The number of items in the list.
Since: 1.4
Throws: ClassCastException If listenerType doesn't specify a class or interface that implements java.util.EventListener.
Since: 1.3
Returns: The index of the selected item.
Returns: The currently selected item.
Returns: An array containing the selected item.
Parameters: item The item to add. index The index at which the item should be inserted.
Throws: IllegalArgumentException If index is less than 0
Returns: A debugging string for this object.
processItemEvent()
if the
event is an instance of ItemEvent
, otherwise the event
is passed to the superclass.
Parameters: event The event to process.
Parameters: event The event to process.
Parameters: item The item to remove.
Throws: IllegalArgumentException If the specified item doesn't exist.
Parameters: index The index of the item to remove.
Throws: IndexOutOfBoundsException If the index is not valid.
Parameters: listener The listener to remove.
Parameters: index The index of the row to make selected.
Throws: IllegalArgumentException If the specified index is invalid.
Parameters: item The item to be selected.
Throws: IllegalArgumentException If the specified item does not exist.