|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Choice
public class Choice
This class implements a drop down choice list.
| Nested Class Summary | |
|---|---|
protected class |
Choice.AccessibleAWTChoice
This class provides accessibility support for the combo box. |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| 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()
Initializes a new instance of Choice. |
|
| Method Summary | ||
|---|---|---|
void |
add(String item)
Adds the specified item to this choice box. |
|
void |
addItem(String item)
Adds the specified item to this choice box. |
|
void |
addItemListener(ItemListener listener)
Adds the specified listener to the list of registered listeners for this object. |
|
void |
addNotify()
Creates the native peer for this object. |
|
int |
countItems()
Deprecated. This method is deprecated in favor of getItemCount. |
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this Choice. |
|
String |
getItem(int index)
Returns the item at the specified index in the list. |
|
int |
getItemCount()
Returns the number of items in the list. |
|
ItemListener[] |
getItemListeners()
Returns all registered item listeners. |
|
|
getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners upon this Choice. |
|
int |
getSelectedIndex()
Returns the index of the selected item. |
|
String |
getSelectedItem()
Returns the currently selected item, or null if no item is selected. |
|
Object[] |
getSelectedObjects()
Returns an array with one row containing the selected item. |
|
void |
insert(String item,
int index)
Inserts an item into this Choice. |
|
protected String |
paramString()
Returns a debugging string for this object. |
|
protected void |
processEvent(AWTEvent event)
Processes this event by invoking processItemEvent() if the
event is an instance of ItemEvent, otherwise the event
is passed to the superclass. |
|
protected void |
processItemEvent(ItemEvent event)
Processes item event by dispatching to any registered listeners. |
|
void |
remove(int index)
Removes the item at the specified index from the choice box. |
|
void |
remove(String item)
Removes the specified item from the choice box. |
|
void |
removeAll()
Removes all of the objects from this choice box. |
|
void |
removeItemListener(ItemListener listener)
Removes the specified listener from the list of registered listeners for this object. |
|
void |
select(int index)
Forces the item at the specified index to be selected. |
|
void |
select(String item)
Forces the named item to be selected. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Choice()
Choice.
HeadlessException - If GraphicsEnvironment.isHeadless()
returns true| Method Detail |
|---|
public int getItemCount()
public int countItems()
getItemCount.
public String getItem(int index)
index - The index into the list to return the item from.
ArrayIndexOutOfBoundsException - If the index is invalid.public void add(String item)
item - The item to add.
NullPointerException - If the item's value is nullpublic void addItem(String item)
add(String) instead.
item - The item to add.
NullPointerException - If the item's value is equal to null
public void insert(String item,
int index)
item - The item to add.index - The index at which the item should be inserted.
IllegalArgumentException - If index is less than 0public void remove(String item)
item - The item to remove.
IllegalArgumentException - If the specified item doesn't exist.public void remove(int index)
index - The index of the item to remove.
IndexOutOfBoundsException - If the index is not valid.public void removeAll()
public String getSelectedItem()
public Object[] getSelectedObjects()
getSelectedObjects in interface ItemSelectablepublic int getSelectedIndex()
public void select(int index)
index - The index of the row to make selected.
IllegalArgumentException - If the specified index is invalid.public void select(String item)
item - The item to be selected.
IllegalArgumentException - If the specified item does not exist.public void addNotify()
addNotify in class ComponentComponent.isDisplayable(),
Component.removeNotify()public void addItemListener(ItemListener listener)
addItemListener in interface ItemSelectablelistener - The listener to add.public void removeItemListener(ItemListener listener)
removeItemListener in interface ItemSelectablelistener - The listener to remove.protected void processEvent(AWTEvent event)
processItemEvent() if the
event is an instance of ItemEvent, otherwise the event
is passed to the superclass.
processEvent in class Componentevent - The event to process.Component.processComponentEvent(ComponentEvent),
Component.processFocusEvent(FocusEvent),
Component.processKeyEvent(KeyEvent),
Component.processMouseEvent(MouseEvent),
Component.processMouseMotionEvent(MouseEvent),
Component.processInputMethodEvent(InputMethodEvent),
Component.processHierarchyEvent(HierarchyEvent),
Component.processMouseWheelEvent(MouseWheelEvent)protected void processItemEvent(ItemEvent event)
event - The event to process.protected String paramString()
paramString in class Componentpublic <T extends EventListener> T[] getListeners(Class<T> listenerType)
getListeners in class ComponentlistenerType - the class of listeners to filter (null
not permitted).
ClassCastException - If listenerType doesn't specify a class or
interface that implements java.util.EventListener.Component.getComponentListeners(),
Component.getFocusListeners(),
Component.getHierarchyListeners(),
Component.getHierarchyBoundsListeners(),
Component.getKeyListeners(),
Component.getMouseListeners(),
Component.getMouseMotionListeners(),
Component.getMouseWheelListeners(),
Component.getInputMethodListeners(),
Component.getPropertyChangeListeners()public ItemListener[] getItemListeners()
public AccessibleContext getAccessibleContext()
Choice.
The context is created, if necessary.
getAccessibleContext in interface AccessiblegetAccessibleContext in class Component
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||