java.awt
Class Choice

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Choice
All Implemented Interfaces:
java.awt.image.ImageObserver

public class Choice
extends Component

The Choice class is a pop-up menu of choices. The current choice is displayed as the title of the menu.


Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Choice()
          Constructs a new Choice.
 
Method Summary
 void addItem(String item)
          Adds an item to this Choice.
 void addNotify()
          Creates the Choice's peer.
 int countItems()
          Returns the number of items in this Choice.
 String getItem(int index)
          Returns the String at the specified index in the Choice.
 int getSelectedIndex()
          Returns the index of the currently selected item.
 String getSelectedItem()
          Returns a String representation of the current choice.
protected  String paramString()
          Returns the parameter String of this Choice.
 void select(int pos)
          Selects the item with the specified postion.
 void select(String str)
          Selects the item with the specified String.
 
Methods inherited from class java.awt.Component
action, bounds, checkImage, checkImage, createImage, createImage, deliverEvent, disable, enable, enable, getBackground, getColorModel, getFont, getFontMetrics, getForeground, getGraphics, getParent, getPeer, getToolkit, gotFocus, handleEvent, hide, imageUpdate, inside, invalidate, isEnabled, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, removeNotify, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setFont, setForeground, show, show, size, toString, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Choice

public Choice()
Constructs a new Choice.

Method Detail

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
See Also:
Component.getPeer(), Component.removeNotify()

countItems

public int countItems()
Returns the number of items in this Choice.

See Also:
getItem(int)

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:
countItems()

addItem

public 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.

getSelectedItem

public String getSelectedItem()
Returns a String representation of the current choice.

See Also:
getSelectedIndex()

getSelectedIndex

public int getSelectedIndex()
Returns the index of the currently selected item.

See Also:
getSelectedItem()

select

public 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()

select

public void select(String str)
Selects the item with the specified String.

Parameters:
str - the specified String
See Also:
getSelectedItem(), getSelectedIndex()

paramString

protected String paramString()
Returns the parameter String of this Choice.

Overrides:
paramString in class Component