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.


Constructor Index

 o Choice()
Constructs a new Choice.

Method Index

 o add(String)
Adds an item to this Choice.
 o addItem(String)
Adds an item to this Choice.
 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.
 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 getSelectedItem()
Returns a String representation of the current choice.
 o getSelectedObjects()
Returns an array (length 1) containing the currently selected item.
 o insert(String, int)
Inserts the item into this choice at the specified position.
 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.

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()
Note: countItems() is deprecated. As of JDK version 1.1, 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)
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 insert
 public synchronized void insert(String item,
                                 int index)
Inserts the item into this choice at the specified position.

Parameters:
item - the item to be inserted
index - the position at which the item should be inserted
Throws: IllegalArgumentException
if index is less than 0.
 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
 o getSelectedItem
 public synchronized String getSelectedItem()
Returns a String representation of the current choice.

See Also:
getSelectedIndex
 o getSelectedObjects
 public synchronized Object[] getSelectedObjects()
Returns an array (length 1) containing the currently selected item. If this choice has no items, returns null.

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

See Also:
getSelectedItem
 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 synchronized void addItemListener(ItemListener l)
Adds the specified item listener to recieve item events from this choice.

Parameters:
l - the item listener
 o removeItemListener
 public synchronized 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

Submit a bug or feature