All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Choice

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

public class Choice
extends Component
implements ItemSelectable
The Choice class is a pop-up menu of choices. The current choice is displayed as the title of the menu.


Variable Index

 o itemListener

Constructor Index

 o Choice()
Constructs a new Choice.

Method Index

 o add(String)
Adds an item to this Choice.
 o addItem(String)
DEPRECATED: Replaced by add(String).
 o addItemListener(ItemListener)
Adds the specified item listener to recieve item events from this choice.
 o addNotify()
Creates the Choice's peer.
 o countItems()
DEPRECATED: Replaced by getItemCount().
 o getItem(int)
Returns the String at the specified index in the Choice.
 o getItemCount()
Returns the number of items in this Choice.
 o getSelectedIndex()
Returns the index of the currently selected item.
 o getSelectedIndexes()
Returns an array (length 1) containing the currently selected item.
 o getSelectedItem()
Returns a String representation of the current choice.
 o getSelectedItems()
Returns an array (length 1) containing the currently selected item
 o paramString()
Returns the parameter String of this Choice.
 o processEvent(AWTEvent)
Processes events on this choice.
 o processItemEvent(ItemEvent)
Processes item events occurring on this choice by dispatching them to any registered ItemListener objects.
 o remove(int)
Removes an item from the choice menu.
 o remove(String)
Remove the first occurrence of item from the choice menu.
 o removeAll()
Removes all items from the choice menu.
 o removeItemListener(ItemListener)
Removes the specified item listener so that it no longer receives item events from this choice.
 o select(int)
Selects the item with the specified postion.
 o select(String)
Selects the item with the specified String.

Variables

 o itemListener
  protected ItemListener itemListener

Constructors

 o Choice
  public Choice()
Constructs a new Choice.

Methods

 o addNotify
  public void addNotify()
Creates the Choice's peer. This peer allows us to change the look of the Choice without changing its functionality.

Overrides:
addNotify in class Component
 o getItemCount
  public int getItemCount()
Returns the number of items in this Choice.

See Also:
getItem
 o countItems
  public int countItems()
DEPRECATED: Replaced by getItemCount().

 o getItem
  public String getItem(int index)
Returns the String at the specified index in the Choice.

Parameters:
index - the index at which to begin
See Also:
getItemCount
 o add
  public synchronized void add(String item)
Adds an item to this Choice.

Parameters:
item - the item to be added
Throws: NullPointerException
If the item's value is equal to null.
 o addItem
  public synchronized void addItem(String item)
DEPRECATED: Replaced by add(String).

 o remove
  public synchronized void remove(String item)
Remove the first occurrence of item from the choice menu.

Parameters:
item - the item to remove from the choice menu
Throws: IllegalArgumentException
If the item doesn't exist in the choice menu.
 o remove
  public synchronized void remove(int position)
Removes an item from the choice menu.

 o removeAll
  public synchronized void removeAll()
Removes all items from the choice menu.

See Also:
remove, delItems
 o getSelectedItem
  public synchronized String getSelectedItem()
Returns a String representation of the current choice.

See Also:
getSelectedIndex
 o getSelectedItems
  public synchronized String[] getSelectedItems()
Returns an array (length 1) containing the currently selected item

See Also:
, getSelectedIndex
 o getSelectedIndex
  public int getSelectedIndex()
Returns the index of the currently selected item.

See Also:
getSelectedItem
 o getSelectedIndexes
  public synchronized int[] getSelectedIndexes()
Returns an array (length 1) containing the currently selected item.

See Also:
ItemSelectable.
 o select
  public synchronized void select(int pos)
Selects the item with the specified postion.

Parameters:
pos - the choice item position
Throws: IllegalArgumentException
If the choice item position is invalid.
See Also:
getSelectedItem, getSelectedIndex
 o select
  public synchronized void select(String str)
Selects the item with the specified String.

Parameters:
str - the specified String
See Also:
getSelectedItem, getSelectedIndex
 o addItemListener
  public void addItemListener(ItemListener l)
Adds the specified item listener to recieve item events from this choice.

Parameters:
l - the item listener
 o removeItemListener
  public void removeItemListener(ItemListener l)
Removes the specified item listener so that it no longer receives item events from this choice.

Parameters:
l - the item listener
 o processEvent
  protected void processEvent(AWTEvent e)
Processes events on this choice. If the event is an ItemEvent, it invokes the handleItemEvent method, else it calls its superclass's processEvent.

Parameters:
e - the event
Overrides:
processEvent in class Component
 o processItemEvent
  protected void processItemEvent(ItemEvent e)
Processes item events occurring on this choice by dispatching them to any registered ItemListener objects. NOTE: This method will not be called unless item events are enabled for this component; this happens when one of the following occurs: a) An ItemListener object is registered via addItemListener() b) Item events are enabled via enableEvents()

Parameters:
e - the item event
See Also:
enableEvents
 o paramString
  protected String paramString()
Returns the parameter String of this Choice.

Overrides:
paramString in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index