Top Description Inners Fields Constructors Methods
java.awt

public Class Choice

extends Component
implements ItemSelectable, Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible, java.awt.ItemSelectable
Imports
java.awt.event.ItemEvent, .ItemListener, java.awt.peer.ChoicePeer, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, java.util.EventListener, .Vector, javax.accessibility.Accessible, .AccessibleAction, .AccessibleContext, .AccessibleRole

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:

The following text describes the
graphic

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.

Authors
Sami Shaio, Arthur van Hoff
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
Choice.AccessibleAWTChoice

This class implements accessibility support for the Choice class.

Field Summary

Modifier and TypeField and Description
private static final String
private int
choiceSerializedDataVersion

Serialized data version.

pack-priv transient ItemListener
private static int
pack-priv Vector<String>
pItems

The items for the Choice.

pack-priv int
selectedIndex

The index of the current choice for this Choice or -1 if nothing is selected.

private static final long
serialVersionUID

Hides java.awt.Component.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.
Inherited from java.awt.Component:
accessibleContextactionListenerKadjustmentListenerKappContextbackgroundbackgroundEraseDisabledBOTTOM_ALIGNMENTCENTER_ALIGNMENTcomponentListenercomponentListenerKcomponentOrientationcontainerListenerKcursordropTargetenabledeventCacheeventMaskfocusListenerfocusListenerKfocusTraversalKeysfontforegroundheighthierarchyBoundsListenerhierarchyBoundsListenerKhierarchyListenerhierarchyListenerKignoreRepaintincRateinputMethodListenerinputMethodListenerKisIncisPackeditemListenerKkeyListenerkeyListenerKLEFT_ALIGNMENTlocaleLOCKmaxSizemaxSizeSetminSizeminSizeSetmouseListenermouseListenerKmouseMotionListenermouseMotionListenerKmouseWheelListenermouseWheelListenerKnewEventsOnlyownedWindowKparentpeerpeerFontpopupsprefSizeprefSizeSetRIGHT_ALIGNMENTtextListenerKTOP_ALIGNMENTvisiblewidthwindowFocusListenerKwindowListenerKwindowStateListenerKxy

Constructor Summary

AccessConstructor and Description
public
Choice()

Creates a new choice menu.

Method Summary

Modifier and TypeMethod and Description
public void
add(String
the item to be added
item
)

Adds an item to this Choice menu.

public void
addItem(String
the item to be added
item
)

Obsolete as of Java 2 platform v1.1.

public synchronized void
addItemListener(ItemListener
the item listener
l
)

Implements java.awt.ItemSelectable.addItemListener.

Adds the specified item listener to receive item events from this Choice menu.
public void
addNotify()

Overrides java.awt.Component.addNotify.

Creates the Choice's peer.
pack-priv String
constructComponentName()

Overrides java.awt.Component.constructComponentName.

Constructs a name for this component.
public int

Returns:

the number of items in this Choice menu
countItems
()

Deprecated As of JDK version 1.1, replaced by getItemCount().
Returns the number of items in this Choice menu.
pack-priv boolean
public AccessibleContext

Returns:

an AccessibleAWTChoice that serves as the AccessibleContext of this Choice
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this Choice.
public String

Returns:

the item at the specified index
getItem
(int
the index at which to begin
index
)

Gets the string at the specified index in this Choice menu.

public int

Returns:

the number of items in this Choice menu
getItemCount
()

Returns the number of items in this Choice menu.

pack-priv final String
getItemImpl(int index)

public synchronized ItemListener[]

Returns:

all of this choice's ItemListeners or an empty array if no item listeners are currently registered
getItemListeners
()

Returns an array of all the item listeners registered on this choice.

public <T extends EventListener> T[]

Returns:

an array of all objects registered as FooListeners on this choice, or an empty array if no such listeners have been added
getListeners
(Class<T>
the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
listenerType
)

Overrides java.awt.Component.getListeners.

Returns an array of all the objects currently registered as FooListeners upon this Choice.
public int

Returns:

the index of the currently selected item, or -1 if nothing is currently selected
getSelectedIndex
()

Returns the index of the currently selected item.

public synchronized String

Returns:

a string representation of the currently selected item in this choice menu
getSelectedItem
()

Gets a representation of the current choice as a string.

public synchronized Object[]
getSelectedObjects()

Implements java.awt.ItemSelectable.getSelectedObjects.

Returns an array (length 1) containing the currently selected item.
private static native void
initIDs()

Hides java.awt.Component.initIDs.

Initialize JNI field and method IDs
public void
insert(String
the non-null item to be inserted
item
,
int
the position at which the item should be inserted
index
)

Inserts the item into this choice at the specified position.

private void
insertNoInvalidate(String
the item to be added
item
,
int
the new item position
index
)

Inserts an item to this Choice, but does not invalidate the Choice.

protected String

Returns:

the parameter string of this Choice menu
paramString
()

Overrides java.awt.Component.paramString.

Returns a string representing the state of this Choice menu.
protected void
processEvent(AWTEvent
the event
e
)

Overrides java.awt.Component.processEvent.

Processes events on this choice.
protected void
processItemEvent(ItemEvent
the item event
e
)

Processes item events occurring on this Choice menu by dispatching them to any registered ItemListener objects.

private void
readObject(ObjectInputStream
the ObjectInputStream to read
s
)

Hides java.awt.Component.readObject.

Reads the ObjectInputStream and if it isn't null adds a listener to receive item events fired by the Choice item.
public void
remove(String
the item to remove from this Choice menu
item
)

Removes the first occurrence of item from the Choice menu.

public void
remove(int
the position of the item
position
)

Removes an item from the choice menu at the specified position.

public void
removeAll()

Removes all items from the choice menu.

public synchronized void
removeItemListener(ItemListener
the item listener
l
)

Implements java.awt.ItemSelectable.removeItemListener.

Removes the specified item listener so that it no longer receives item events from this Choice menu.
private void
removeNoInvalidate(int
the position of the item
position
)

Removes an item from the Choice at the specified position, but does not invalidate the Choice.

public synchronized void
select(int
the position of the selected item
pos
)

Sets the selected item in this Choice menu to be the item at the specified position.

public synchronized void
select(String
the specified string
str
)

Sets the selected item in this Choice menu to be the item whose name is equal to the specified string.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write
s
)

Hides java.awt.Component.writeObject.

Writes default serializable fields to stream.
Inherited from java.awt.Component:
actionaddaddComponentListeneraddFocusListeneraddHierarchyBoundsListeneraddHierarchyListeneraddInputMethodListeneraddKeyListeneraddMouseListeneraddMouseMotionListeneraddMouseWheelListeneraddPropertyChangeListeneraddPropertyChangeListeneradjustListeningChildrenOnParentapplyComponentOrientationapplyCompoundShapeapplyCurrentShapeareBoundsValidareFocusTraversalKeysSetareInputMethodsEnabledautoProcessMouseWheelboundscanBeFocusOwnercanBeFocusOwnerRecursivelycheckGDcheckImagecheckImagecheckTreeLockclearCurrentFocusCycleRootOnHideclearMostRecentFocusOwnerOnHidecoalesceEventscontainscontainscontainsFocuscountHierarchyMemberscreateBufferStrategycreateBufferStrategycreateHierarchyEventscreateImagecreateImagecreateVolatileImagecreateVolatileImagedeliverEventdisabledisableEventsdispatchEventdispatchEventImpldispatchMouseWheelToAncestordoLayoutenableenableenableEventsenableInputMethodseventTypeEnabledfindUnderMouseInWindowfirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangegetAccessControlContextgetAccessibleIndexInParentgetAccessibleStateSetgetAlignmentXgetAlignmentYgetBackBuffergetBackgroundgetBaselinegetBaselineResizeBehaviorgetBoundsgetBoundsgetBoundsOpgetBufferStrategygetColorModelgetComponentAtgetComponentAtgetComponentFactorygetComponentListenersgetComponentOrientationgetContainergetContainingWindowgetCursorgetCursor_NoClientCodegetDropTargetgetFocusCycleRootAncestorgetFocusListenersgetFocusTraversalKeysgetFocusTraversalKeys_NoIDCheckgetFocusTraversalKeysEnabledgetFontgetFont_NoClientCodegetFontMetricsgetForegroundgetGraphicsgetGraphics_NoClientCodegetGraphicsConfigurationgetGraphicsConfiguration_NoClientCodegetHeightgetHierarchyBoundsListenersgetHierarchyListenersgetHWPeerAboveMegetIgnoreRepaintgetInputContextgetInputMethodListenersgetInputMethodRequestsgetKeyListenersgetLocalegetLocationgetLocationgetLocationOnScreengetLocationOnScreen_NoTreeLockgetLocationOnWindowgetMaximumSizegetMinimumSizegetMouseListenersgetMouseMotionListenersgetMousePositiongetMouseWheelListenersgetNamegetNativeContainergetNextFocusCandidategetNormalShapegetObjectLockgetOpaqueShapegetParentgetParent_NoClientCodegetPreferredSizegetPropertyChangeListenersgetPropertyChangeListenersgetSiblingIndexAbovegetSiblingIndexBelowgetSizegetSizegetToolkitgetToolkitImplgetTraversalRootgetTreeLockgetWidthgetXgetYgotFocushandleEventhasFocushideimageUpdateinitializeFocusTraversalKeysinsideinvalidateinvalidateIfValidinvalidateParentisAutoFocusTransferOnDisposalisBackgroundSetisCoalescingEnabledisCursorSetisDisplayableisDoubleBufferedisEnabledisEnabledImplisFocusableisFocusCycleRootisFocusOwnerisFocusTraversableisFocusTraversableOverriddenisFontSetisForegroundSetisInstanceOfisLightweightisMaximumSizeSetisMinimumSizeSetisMixingNeededisNonOpaqueForMixingisOpaqueisPreferredSizeSetisRecursivelyVisibleisSameOrAncestorOfisShowingisValidisVisibleisVisible_NoClientCodekeyDownkeyUplayoutlightweightPaintlightweightPrintlistlistlistlistlistlocatelocationlostFocusminimumSizemixOnHidingmixOnReshapingmixOnShowingmixOnValidatingmixOnZOrderChangingmouseDownmouseDragmouseEntermouseExitmouseMovemouseUpmovenextFocusnumListeningpaintpaintAllpaintHeavyweightComponentspointRelativeToComponentpostEventpostsOldMouseEventspreferredSizeprepareImageprepareImageprintprintAllprintHeavyweightComponentsprocessComponentEventprocessFocusEventprocessHierarchyBoundsEventprocessHierarchyEventprocessInputMethodEventprocessKeyEventprocessMouseEventprocessMouseMotionEventprocessMouseWheelEventrelocateComponentremoveremoveComponentListenerremoveFocusListenerremoveHierarchyBoundsListenerremoveHierarchyListenerremoveInputMethodListenerremoveKeyListenerremoveMouseListenerremoveMouseMotionListenerremoveMouseWheelListenerremoveNotifyremovePropertyChangeListenerremovePropertyChangeListenerrepaintrepaintrepaintrepaintrequestFocusrequestFocusrequestFocusrequestFocusrequestFocusHelperrequestFocusHelperrequestFocusInWindowrequestFocusInWindowrequestFocusInWindowrequestFocusInWindowreshaperesizeresizerevalidaterevalidateSynchronouslysetAutoFocusTransferOnDisposalsetBackgroundsetBoundssetBoundssetBoundsOpsetComponentOrientationsetCursorsetDropTargetsetEnabledsetFocusablesetFocusTraversalKeyssetFocusTraversalKeys_NoIDChecksetFocusTraversalKeysEnabledsetFontsetForegroundsetGraphicsConfigurationsetIgnoreRepaintsetLocalesetLocationsetLocationsetMaximumSizesetMinimumSizesetMixingCutoutShapesetNamesetPreferredSizesetRequestFocusControllersetSizesetSizesetVisibleshowshowsizesubtractAndApplyShapesubtractAndApplyShapeBelowMetoStringtransferFocustransferFocustransferFocusBackwardtransferFocusBackwardtransferFocusUpCycleupdateupdateChildGraphicsDataupdateCursorImmediatelyupdateGraphicsDataupdateZOrdervalidate

Field Detail

baseback to summary
private static final String base
choiceSerializedDataVersionback to summary
private int choiceSerializedDataVersion

Serialized data version.

itemListenerback to summary
pack-priv transient ItemListener itemListener
nameCounterback to summary
private static int nameCounter
pItemsback to summary
pack-priv Vector<String> pItems

The items for the Choice. This can be a null value.

See Also
add(String), addItem(String), getItem(int), getItemCount(), insert(String, int), remove(String)
selectedIndexback to summary
pack-priv int selectedIndex

The index of the current choice for this Choice or -1 if nothing is selected.

See Also
getSelectedItem(), select(int)
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.Component.serialVersionUID.

Use serialVersionUID from JDK 1.1 for interoperability.

Annotations
@Serial

Constructor Detail

Choiceback to summary
public Choice() throws HeadlessException

Creates a new choice menu. The menu initially has no items in it.

By default, the first item added to the choice menu becomes the selected item, until a different selection is made by the user by calling one of the select methods.

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
See Also
java.awt.GraphicsEnvironment#isHeadless, select(int), select(java.lang.String)

Method Detail

addback to summary
public void add(String item)

Adds an item to this Choice menu.

Parameters
item:String

the item to be added

Exceptions
NullPointerException:
if the item's value is null
Since
1.1
addItemback to summary
public void addItem(String item)

Obsolete as of Java 2 platform v1.1. Please use the add method instead.

Adds an item to this Choice menu.

Parameters
item:String

the item to be added

Exceptions
NullPointerException:
if the item's value is equal to null
addItemListenerback to summary
public synchronized void addItemListener(ItemListener l)

Implements java.awt.ItemSelectable.addItemListener.

Adds the specified item listener to receive item events from this Choice menu. Item events are sent in response to user input, but not in response to calls to select. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters
l:ItemListener

the item listener

Since
1.1
See Also
removeItemListener, getItemListeners, select, java.awt.event.ItemEvent, java.awt.event.ItemListener
addNotifyback to summary
public void addNotify()

Overrides java.awt.Component.addNotify.

Creates the Choice's peer. This peer allows us to change the look of the Choice without changing its functionality.

See Also
java.awt.Component#getToolkit()
constructComponentNameback to summary
pack-priv String constructComponentName()

Overrides java.awt.Component.constructComponentName.

Constructs a name for this component. Called by getName when the name is null.

countItemsback to summary
public int countItems()

Deprecated

As of JDK version 1.1, replaced by getItemCount().

Returns the number of items in this Choice menu.

Returns:int

the number of items in this Choice menu

Annotations
@Deprecated
eventEnabledback to summary
pack-priv boolean eventEnabled(AWTEvent e)

Overrides java.awt.Component.eventEnabled.

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this Choice. For Choice components, the AccessibleContext takes the form of an AccessibleAWTChoice. A new AccessibleAWTChoice instance is created if necessary.

Returns:AccessibleContext

an AccessibleAWTChoice that serves as the AccessibleContext of this Choice

Since
1.3
getItemback to summary
public String getItem(int index)

Gets the string at the specified index in this Choice menu.

Parameters
index:int

the index at which to begin

Returns:String

the item at the specified index

See Also
getItemCount
getItemCountback to summary
public int getItemCount()

Returns the number of items in this Choice menu.

Returns:int

the number of items in this Choice menu

Since
1.1
See Also
getItem
getItemImplback to summary
pack-priv final String getItemImpl(int index)
getItemListenersback to summary
public synchronized ItemListener[] getItemListeners()

Returns an array of all the item listeners registered on this choice.

Returns:ItemListener[]

all of this choice's ItemListeners or an empty array if no item listeners are currently registered

Since
1.4
See Also
addItemListener, removeItemListener, java.awt.event.ItemEvent, java.awt.event.ItemListener
getListenersback to summary
public <T extends EventListener> T[] getListeners(Class<T> listenerType)

Overrides java.awt.Component.getListeners.

Returns an array of all the objects currently registered as FooListeners upon this Choice. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Choice c for its item listeners with the following code:

ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));
If no such listeners exist, this method returns an empty array.
Parameters
<T>

Doc from java.awt.Component.getListeners. the type of the listeners

listenerType:Class<T>

the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener

Returns:T[]

an array of all objects registered as FooListeners on this choice, or an empty array if no such listeners have been added

Exceptions
ClassCastException:
if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since
1.3
See Also
getItemListeners
getSelectedIndexback to summary
public int getSelectedIndex()

Returns the index of the currently selected item. If nothing is selected, returns -1.

Returns:int

the index of the currently selected item, or -1 if nothing is currently selected

See Also
getSelectedItem
getSelectedItemback to summary
public synchronized String getSelectedItem()

Gets a representation of the current choice as a string.

Returns:String

a string representation of the currently selected item in this choice menu

See Also
getSelectedIndex
getSelectedObjectsback to summary
public synchronized Object[] getSelectedObjects()

Implements java.awt.ItemSelectable.getSelectedObjects.

Returns an array (length 1) containing the currently selected item. If this choice has no items, returns null.

Returns:Object[]

Doc from java.awt.ItemSelectable.getSelectedObjects.

the list of selected objects, or null

See Also
ItemSelectable
initIDsback to summary
private static native void initIDs()

Hides java.awt.Component.initIDs.

Initialize JNI field and method IDs

insertback to summary
public void insert(String item, int index)

Inserts the item into this choice at the specified position. Existing items at an index greater than or equal to index are shifted up by one to accommodate the new item. If index is greater than or equal to the number of items in this choice, item is added to the end of this choice.

If the item is the first one being added to the choice, then the item becomes selected. Otherwise, if the selected item was one of the items shifted, the first item in the choice becomes the selected item. If the selected item was no among those shifted, it remains the selected item.

Parameters
item:String

the non-null item to be inserted

index:int

the position at which the item should be inserted

Exceptions
IllegalArgumentException:
if index is less than 0
insertNoInvalidateback to summary
private void insertNoInvalidate(String item, int index)

Inserts an item to this Choice, but does not invalidate the Choice. Client methods must provide their own synchronization before invoking this method.

Parameters
item:String

the item to be added

index:int

the new item position

Exceptions
NullPointerException:
if the item's value is equal to null
paramStringback to summary
protected String paramString()

Overrides java.awt.Component.paramString.

Returns a string representing the state of this Choice menu. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Returns:String

the parameter string of this Choice menu

processEventback to summary
protected void processEvent(AWTEvent e)

Overrides java.awt.Component.processEvent.

Processes events on this choice. If the event is an instance of ItemEvent, it invokes the processItemEvent method. Otherwise, it calls its superclass's processEvent method.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters
e:AWTEvent

the event

Since
1.1
See Also
java.awt.event.ItemEvent, processItemEvent
processItemEventback to summary
protected void processItemEvent(ItemEvent e)

Processes item events occurring on this Choice menu by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:

  • An ItemListener object is registered via addItemListener.
  • Item events are enabled via enableEvents.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters
e:ItemEvent

the item event

Since
1.1
See Also
java.awt.event.ItemEvent, java.awt.event.ItemListener, addItemListener(ItemListener), java.awt.Component#enableEvents
readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException

Hides java.awt.Component.readObject.

Reads the ObjectInputStream and if it isn't null adds a listener to receive item events fired by the Choice item. Unrecognized keys or values will be ignored.

Parameters
s:ObjectInputStream

the ObjectInputStream to read

Annotations
@Serial
Exceptions
ClassNotFoundException:
if the class of a serialized object could not be found
IOException:
if an I/O error occurs
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
See Also
removeItemListener(ItemListener), addItemListener(ItemListener), java.awt.GraphicsEnvironment#isHeadless, writeObject(ObjectOutputStream)
removeback to summary
public void remove(String item)

Removes the first occurrence of item from the Choice menu. If the item being removed is the currently selected item, then the first item in the choice becomes the selected item. Otherwise, the currently selected item remains selected (and the selected index is updated accordingly).

Parameters
item:String

the item to remove from this Choice menu

Exceptions
IllegalArgumentException:
if the item doesn't exist in the choice menu
Since
1.1
removeback to summary
public void remove(int position)

Removes an item from the choice menu at the specified position. If the item being removed is the currently selected item, then the first item in the choice becomes the selected item. Otherwise, the currently selected item remains selected (and the selected index is updated accordingly).

Parameters
position:int

the position of the item

Exceptions
IndexOutOfBoundsException:
if the specified position is out of bounds
Since
1.1
removeAllback to summary
public void removeAll()

Removes all items from the choice menu.

Since
1.1
See Also
remove
removeItemListenerback to summary
public synchronized void removeItemListener(ItemListener l)

Implements java.awt.ItemSelectable.removeItemListener.

Removes the specified item listener so that it no longer receives item events from this Choice menu. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.

Parameters
l:ItemListener

the item listener

Since
1.1
See Also
addItemListener, getItemListeners, java.awt.event.ItemEvent, java.awt.event.ItemListener
removeNoInvalidateback to summary
private void removeNoInvalidate(int position)

Removes an item from the Choice at the specified position, but does not invalidate the Choice. Client methods must provide their own synchronization before invoking this method.

Parameters
position:int

the position of the item

selectback to summary
public synchronized void select(int pos)

Sets the selected item in this Choice menu to be the item at the specified position.

Note that this method should be primarily used to initially select an item in this component. Programmatically calling this method will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction.

Parameters
pos:int

the position of the selected item

Exceptions
IllegalArgumentException:
if the specified position is greater than the number of items or less than zero
See Also
getSelectedItem, getSelectedIndex
selectback to summary
public synchronized void select(String str)

Sets the selected item in this Choice menu to be the item whose name is equal to the specified string. If more than one item matches (is equal to) the specified string, the one with the smallest index is selected.

Note that this method should be primarily used to initially select an item in this component. Programmatically calling this method will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction.

Parameters
str:String

the specified string

See Also
getSelectedItem, getSelectedIndex
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides java.awt.Component.writeObject.

Writes default serializable fields to stream. Writes a list of serializable ItemListeners as optional data. The non-serializable ItemListeners are detected and no attempt is made to serialize them.

Parameters
s:ObjectOutputStream

the ObjectOutputStream to write

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
Serial data
null terminated sequence of 0 or more pairs; the pair consists of a String and an Object; the String indicates the type of object and is one of the following: itemListenerK indicating an ItemListener object
See Also
AWTEventMulticaster#save(ObjectOutputStream, String, EventListener), java.awt.Component#itemListenerK, readObject(ObjectInputStream)
java.awt back to summary

protected Class Choice.AccessibleAWTChoice

extends AccessibleAWTComponent
implements AccessibleAction
Class Inheritance
All Implemented Interfaces
javax.accessibility.AccessibleAction

This class implements accessibility support for the Choice class. It provides an implementation of the Java Accessibility API appropriate to choice user-interface elements.
Since
1.3

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Hides java.awt.Component.AccessibleAWTComponent.serialVersionUID.

Use serialVersionUID from JDK 1.3 for interoperability.
Inherited from java.awt.Component.AccessibleAWTComponent:
accessibleAWTComponentHandleraccessibleAWTFocusHandler

Constructor Summary

AccessConstructor and Description
public
AccessibleAWTChoice()

Constructor for AccessibleAWTChoice

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the action was performed; otherwise false.
doAccessibleAction
(int
zero-based index of actions
i
)

Implements javax.accessibility.AccessibleAction.doAccessibleAction.

Perform the specified Action on the object
public AccessibleAction

Returns:

this object
getAccessibleAction
()

Overrides javax.accessibility.AccessibleContext.getAccessibleAction.

Get the AccessibleAction associated with this object.
public int

Returns:

the zero-based number of Actions in this object
getAccessibleActionCount
()

Implements javax.accessibility.AccessibleAction.getAccessibleActionCount.

Returns the number of accessible actions available in this object If there are more than one, the first one is considered the "default" action of the object.
public String

Returns:

a String description of the action
getAccessibleActionDescription
(int
zero-based index of the actions
i
)

Implements javax.accessibility.AccessibleAction.getAccessibleActionDescription.

Returns a description of the specified action of the object.
public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides java.awt.Component.AccessibleAWTComponent.getAccessibleRole.

Get the role of this object.
Inherited from java.awt.Component.AccessibleAWTComponent:
addFocusListeneraddPropertyChangeListenercontainsgetAccessibleAtgetAccessibleChildgetAccessibleChildrenCountgetAccessibleComponentgetAccessibleDescriptiongetAccessibleIndexInParentgetAccessibleNamegetAccessibleParentgetAccessibleStateSetgetBackgroundgetBoundsgetCursorgetFontgetFontMetricsgetForegroundgetLocalegetLocationgetLocationOnScreengetSizeisEnabledisFocusTraversableisShowingisVisibleremoveFocusListenerremovePropertyChangeListenerrequestFocussetBackgroundsetBoundssetCursorsetEnabledsetFontsetForegroundsetLocationsetSizesetVisible

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.Component.AccessibleAWTComponent.serialVersionUID.

Use serialVersionUID from JDK 1.3 for interoperability.

Annotations
@Serial

Constructor Detail

AccessibleAWTChoiceback to summary
public AccessibleAWTChoice()

Constructor for AccessibleAWTChoice

Method Detail

doAccessibleActionback to summary
public boolean doAccessibleAction(int i)

Implements javax.accessibility.AccessibleAction.doAccessibleAction.

Perform the specified Action on the object

Parameters
i:int

zero-based index of actions

Returns:boolean

true if the action was performed; otherwise false.

See Also
getAccessibleActionCount
getAccessibleActionback to summary
public AccessibleAction getAccessibleAction()

Overrides javax.accessibility.AccessibleContext.getAccessibleAction.

Get the AccessibleAction associated with this object. In the implementation of the Java Accessibility API for this class, return this object, which is responsible for implementing the AccessibleAction interface on behalf of itself.

Returns:AccessibleAction

this object

See Also
AccessibleAction
getAccessibleActionCountback to summary
public int getAccessibleActionCount()

Implements javax.accessibility.AccessibleAction.getAccessibleActionCount.

Returns the number of accessible actions available in this object If there are more than one, the first one is considered the "default" action of the object.

Returns:int

the zero-based number of Actions in this object

getAccessibleActionDescriptionback to summary
public String getAccessibleActionDescription(int i)

Implements javax.accessibility.AccessibleAction.getAccessibleActionDescription.

Returns a description of the specified action of the object.

Parameters
i:int

zero-based index of the actions

Returns:String

a String description of the action

See Also
getAccessibleActionCount
getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides java.awt.Component.AccessibleAWTComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object

See Also
AccessibleRole