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

Class Choice

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

All Implemented Interfaces:

ItemSelectable, Serializable, ImageObserver, MenuContainer, Serializable


public class Choice

extends Component

implements ItemSelectable, Serializable

This class implements a drop down choice list.

Author:

Constructor Summary

Choice()

Initializes a new instance of Choice.

Method Summary

synchronized voidadd(java.lang.String item)

Adds the specified item to this choice box.
synchronized voidaddItem(java.lang.String item)

Adds the specified item to this choice box.
synchronized voidaddItemListener(java.awt.event.ItemListener listener)

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

Creates the native peer for this object.
intcountItems()

Returns the number of items in the list.
java.lang.StringgetItem(int index)

Returns the item at the specified index in the list.
intgetItemCount()

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

Returns all registered item listeners.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this Choice.
intgetSelectedIndex()

Returns the index of the selected item.
synchronized java.lang.StringgetSelectedItem()

Returns the currently selected item, or null if no item is selected.
synchronized java.lang.Object[]getSelectedObjects()

Returns an array with one row containing the selected item.
synchronized voidinsert(java.lang.String item, int index)

Inserts an item into this Choice.
java.lang.StringparamString()

Returns a debugging string for this object.
voidprocessEvent(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.
voidprocessItemEvent(java.awt.event.ItemEvent event)

Processes item event by dispatching to any registered listeners.
synchronized voidremove(java.lang.String item)

Removes the specified item from the choice box.
synchronized voidremove(int index)

Removes the item at the specified index from the choice box.
synchronized voidremoveAll()

Removes all of the objects from this choice box.
synchronized voidremoveItemListener(java.awt.event.ItemListener listener)

Removes the specified listener from the list of registered listeners for this object.
synchronized voidselect(int index)

Forces the item at the specified index to be selected.
synchronized voidselect(java.lang.String item)

Forces the named item to be selected.

Constructor Details

Choice

public Choice()

Initializes a new instance of Choice.

Throws:


Method Details

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:


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:


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:


getSelectedIndex

public int getSelectedIndex()

Returns the index of the selected item.

Returns:


getSelectedItem

public synchronized String getSelectedItem()

Returns the currently selected item, or null if no item is selected.

Returns:


getSelectedObjects

public synchronized Object[] getSelectedObjects()

Returns an array with one row containing the selected item.

Returns:


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:


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: