java.lang.Object | +--java.awt.Component | +--java.awt.Choice
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.
| Inner Class Summary | |
protected class |
Choice.AccessibleAWTChoice
Choice.AccessibleAWTChoice
|
| Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
Choice
copy-> new Choice()copy-> <Choice var> = new Choice();
|
|
| Method Summary | |
void |
add(String item)
copy-> .add( )copy-> <Choice>.add(<String item>);
|
void |
addItem(String item)
copy-> .addItem( )copy-> <Choice>.addItem(<String item>);
|
void |
addItemListener(ItemListener l)
copy-> .addItemListener( )copy-> <Choice>.addItemListener(<ItemListener l>);
|
void |
addNotify()
copy-> .addNotify()copy-> <Choice>.addNotify();
|
int |
countItems()
copy-> .countItems()copy-> <int var>=<Choice>.countItems();
|
AccessibleContext |
getAccessibleContext()
copy-> .getAccessibleContext()copy-> <AccessibleContext var>=<Choice>.getAccessibleContext();
|
String |
getItem(int index)
copy-> .getItem( )copy-> <String var>=<Choice>.getItem(<int index>);
|
int |
getItemCount()
copy-> .getItemCount()copy-> <int var>=<Choice>.getItemCount();
|
EventListener[] |
getListeners(Class listenerType)
copy-> .getListeners( )copy-> <EventListener var>=<Choice>.getListeners(<Class listenerType>);
|
int |
getSelectedIndex()
copy-> .getSelectedIndex()copy-> <int var>=<Choice>.getSelectedIndex();
|
String |
getSelectedItem()
copy-> .getSelectedItem()copy-> <String var>=<Choice>.getSelectedItem();
|
Object[] |
getSelectedObjects()
copy-> .getSelectedObjects()copy-> <Object var>=<Choice>.getSelectedObjects();
|
void |
insert(String item,
int index)
copy-> .insert(, )copy-> <Choice>.insert(<String item>, <int index>);
|
protected String |
paramString()
copy-> .paramString()copy-> <String var>=<Choice>.paramString();
|
protected void |
processEvent(AWTEvent e)
copy-> .processEvent( )copy-> <Choice>.processEvent(<AWTEvent e>);
|
protected void |
processItemEvent(ItemEvent e)
copy-> .processItemEvent( )copy-> <Choice>.processItemEvent(<ItemEvent e>);
|
void |
remove(int position)
copy-> .remove( )copy-> <Choice>.remove(<int position>);
|
void |
remove(String item)
copy-> .remove( )copy-> <Choice>.remove(<String item>);
|
void |
removeAll()
copy-> .removeAll()copy-> <Choice>.removeAll();
|
void |
removeItemListener(ItemListener l)
copy-> .removeItemListener( )copy-> <Choice>.removeItemListener(<ItemListener l>);
|
void |
select(int pos)
copy-> .select( )copy-> <Choice>.select(<int pos>);
|
void |
select(String str)
copy-> .select( )copy-> <Choice>.select(<String str>);
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |