|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Choice
, ItemSelectable
, MenuContainer
, Serializable
, Accessible

public class Choice

, Accessible

The Choice class presents a pop-up menu of choices.
The current choice is displayed as the title of the menu.
The following code example produces a pop-up menu:
Choice ColorChooser = new Choice();
ColorChooser.add("Green");
ColorChooser.add("Red");
ColorChooser.add("Blue");
After this choice menu has been added to a panel, it appears as follows in its normal state:
In the picture, "Green" is the current choice.
Pushing the mouse button down on the object causes a menu to
appear with the current choice highlighted.
Some native platforms do not support arbitrary resizing of
Choice components and the behavior of
setSize()/getSize() is bound by
such limitations.
Native GUI Choice components' size are often bound by such
attributes as font size and length of items contained within
the Choice.
| Nested Class Summary | |
|---|---|
protected class |
Choice.AccessibleAWTChoice
This class implements accessibility support for the Choice class. |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary |
|---|
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
Choice
Creates a new choice menu. |
|
| Method Summary | ||
|---|---|---|
void |
add
Adds an item to this Choice menu. |
|
void |
addItem
Obsolete as of Java 2 platform v1.1. |
|
void |
addItemListener
Adds the specified item listener to receive item events from this Choice menu. |
|
void |
addNotify
Creates the Choice's peer. |
|
int |
countItems
Deprecated. As of JDK version 1.1, replaced by getItemCount(). |
|
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this
Choice. |
|
String |
getItem
Gets the string at the specified index in this Choice menu. |
|
int |
getItemCount
Returns the number of items in this Choice menu. |
|
ItemListener |
getItemListeners
Returns an array of all the item listeners registered on this choice. |
|
|
getListeners
Returns an array of all the objects currently registered as FooListeners
upon this Choice. |
|
int |
getSelectedIndex
Returns the index of the currently selected item. |
|
String |
getSelectedItem
Gets a representation of the current choice as a string. |
|
Object |
getSelectedObjects
Returns an array (length 1) containing the currently selected item. |
|
void |
insert
Inserts the item into this choice at the specified position. |
|
protected String |
paramString
Returns a string representing the state of this Choice
menu. |
|
protected void |
processEvent
Processes events on this choice. |
|
protected void |
processItemEvent
Processes item events occurring on this Choice
menu by dispatching them to any registered
ItemListener objects. |
|
void |
remove
Removes an item from the choice menu at the specified position. |
|
void |
remove
Removes the first occurrence of item
from the Choice menu. |
|
void |
removeAll
Removes all items from the choice menu. |
|
void |
removeItemListener
Removes the specified item listener so that it no longer receives item events from this Choice menu. |
|
void |
select
Sets the selected item in this Choice menu to be the
item at the specified position. |
|
void |
select
Sets the selected item in this Choice menu
to be the item whose name is equal to the specified string. |
|