The following picture depicts a menu which contains an instance
of CheckBoxMenuItem:
The item labeled Check shows a check box menu item
in its "off" state.
When a check box menu item is selected, AWT sends an item event to
the item. Since the event is an instance of ItemEvent,
the processEvent method examines the event and passes
it along to processItemEvent. The latter method redirects
the event to any ItemListener objects that have
registered an interest in item events generated by this menu item.
java.awt.event.ItemEvent , java.awt.event.ItemListener
| Modifier and Type | Class and Description |
|---|---|
| protected class | CheckboxMenuItem.
Inner class of CheckboxMenuItem used to provide default support for accessibility. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | base
Hides java. |
| private int | checkboxMenuItemSerializedDataVersion
Serialized data version. |
| private transient volatile ItemListener | |
| private static int | |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| private volatile boolean | state
The state of a checkbox menu item |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CheckboxMenuItem(String
a string label for the check box menu item,
or label)null for an unlabeled menu item.Create a check box menu item with the specified label. |
| public | CheckboxMenuItem(String
a string label for the check box menu item,
or label, boolean null for an unlabeled menu item.the initial state of the menu item, where
state)true indicates "on" and
false indicates "off."Create a check box menu item with the specified label and state. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addItemListener(ItemListener
the item listener l)Implements java. Adds the specified item listener to receive item events from this check box menu item. |
| public void | |
| pack-priv String | constructComponentName()
Overrides java. Construct a name for this MenuComponent. |
| pack-priv void | |
| pack-priv boolean | |
| public AccessibleContext | Returns: an AccessibleAWTCheckboxMenuItem that serves as the AccessibleContext of this CheckboxMenuItemOverrides java. Implements javax. Gets the AccessibleContext associated with this CheckboxMenuItem. |
| public synchronized ItemListener[] | Returns: all of this checkbox menuitem'sItemListeners
or an empty array if no item
listeners are currently registeredReturns an array of all the item listeners registered on this checkbox menuitem. |
| public <T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this checkbox menuitem,
or an empty array if no such
listeners have been addedthe type of listeners requested; this parameter
should specify an interface that descends from
listenerType)java.util.EventListenerOverrides java. Returns an array of all the objects currently registered
as |
| public synchronized Object[] | getSelectedObjects()
Implements java. Returns the array (length 1) containing the checkbox menu item label or null if the checkbox is not selected. |
| public boolean | Returns: the state of this check box menu item, wheretrue indicates "on" and
false indicates "off"Determines whether the state of this check box menu item is "on" or "off." |
| private static native void | |
| public String | Returns: the parameter string of this check box menu itemOverrides java. Returns a string representing the state of this
|
| protected void | processEvent(AWTEvent
the event e)Overrides java. Processes events on this check box menu item. |
| protected void | processItemEvent(ItemEvent
the item event e)Processes item events occurring on this check box menu item by
dispatching them to any registered |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Reads the |
| public synchronized void | removeItemListener(ItemListener
the item listener l)Implements java. Removes the specified item listener so that it no longer receives item events from this check box menu item. |
| public synchronized void | setState(boolean
true if the check box
menu item is on, otherwise falseSets this check box menu item to the specified state. |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to writeHides java. Writes default serializable fields to stream. |
| base | back to summary |
|---|---|
| private static final String base Hides java. | |
| checkboxMenuItemSerializedDataVersion | back to summary |
|---|---|
| private int checkboxMenuItemSerializedDataVersion Serialized data version. | |
| itemListener | back to summary |
|---|---|
| private transient volatile ItemListener itemListener | |
| nameCounter | back to summary |
|---|---|
| private static int nameCounter | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. | |
| state | back to summary |
|---|---|
| private volatile boolean state The state of a checkbox menu item
| |
| CheckboxMenuItem | back to summary |
|---|---|
| public CheckboxMenuItem() throws HeadlessException Create a check box menu item with an empty label. The item's state is initially set to "off."
| |
| CheckboxMenuItem | back to summary |
|---|---|
| public CheckboxMenuItem(String label) throws HeadlessException Create a check box menu item with the specified label. The item's state is initially set to "off."
| |
| CheckboxMenuItem | back to summary |
|---|---|
| public CheckboxMenuItem(String label, boolean state) throws HeadlessException Create a check box menu item with the specified label and state.
| |
| addItemListener | back to summary |
|---|---|
| public synchronized void addItemListener(ItemListener l) Implements java. Adds the specified item listener to receive item events from this check box menu item. Item events are sent in response to user actions, but not in response to calls to setState(). 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.
| |
| addNotify | back to summary |
|---|---|
| public void addNotify() Overrides java. Creates the peer of the checkbox item. This peer allows us to change the look of the checkbox item without changing its functionality. Most applications do not call this method directly.
| |
| constructComponentName | back to summary |
|---|---|
| pack-priv String constructComponentName() Overrides java. Construct a name for this MenuComponent. Called by getName() when the name is null. | |
| doMenuEvent | back to summary |
|---|---|
| pack-priv void doMenuEvent(long when, int modifiers) Overrides java. | |
| eventEnabled | back to summary |
|---|---|
| pack-priv boolean eventEnabled(AWTEvent e) Overrides java. | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this CheckboxMenuItem. For checkbox menu items, the AccessibleContext takes the form of an AccessibleAWTCheckboxMenuItem. A new AccessibleAWTCheckboxMenuItem is created if necessary.
| |
| getItemListeners | back to summary |
|---|---|
| public synchronized ItemListener[] getItemListeners() Returns an array of all the item listeners registered on this checkbox menuitem.
| |
| getListeners | back to summary |
|---|---|
| public <T extends EventListener> T[] getListeners(Class<T> listenerType) Overrides java. Returns an array of all the objects currently registered
as
You can specify the ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));If no such listeners exist, this method returns an empty array.
| |
| getSelectedObjects | back to summary |
|---|---|
| public synchronized Object[] getSelectedObjects() Implements java. Returns the array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
| |
| getState | back to summary |
|---|---|
| public boolean getState() Determines whether the state of this check box menu item is "on" or "off."
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Hides java. Initialize JNI field and method IDs | |
| paramString | back to summary |
|---|---|
| public String paramString() Overrides java. Returns a string representing the state of this
| |
| processEvent | back to summary |
|---|---|
| protected void processEvent(AWTEvent e) Overrides java. Processes events on this check box menu item.
If the event is an instance of Check box menu items currently support only item events. Note that if the event parameter is
| |
| processItemEvent | back to summary |
|---|---|
| protected void processItemEvent(ItemEvent e) Processes item events occurring on this check box menu item by
dispatching them to any registered This method is not called unless item events are enabled for this menu item. Item events are enabled when one of the following occurs:
Note that if the event parameter is
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException Hides java. Reads the
| |
| removeItemListener | back to summary |
|---|---|
| public synchronized void removeItemListener(ItemListener l) Implements java. Removes the specified item listener so that it no longer receives item events from this check box menu item. 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.
| |
| setState | back to summary |
|---|---|
| public synchronized void setState(boolean b) Sets this check box menu item to the specified state.
The boolean value Note that this method should be primarily used to
initialize the state of the check box menu item.
Programmatically setting the state of the check box
menu item will not trigger
an
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides java. Writes default serializable fields to stream. Writes
a list of serializable
| |
This class implements accessibility support for the
CheckboxMenuItem class. It provides an implementation
of the Java Accessibility API appropriate to checkbox menu item
user-interface elements.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides java. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the action was performed; otherwise false.zero-based index of actions i)Overrides java. Implements javax. Perform the specified Action on the object |
| public AccessibleAction | Returns: this objectOverrides java. Get the AccessibleAction associated with this object. |
| public int | Returns: the number of Actions in this objectOverrides java. Implements javax. Returns the number of Actions available in this object. |
| public String | getAccessibleActionDescription(int
zero-based index of the actions i)Overrides java. Implements javax. Return a description of the specified action of the object. |
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides java. Get the role of this object. |
| public AccessibleValue | Returns: this objectOverrides java. Get the AccessibleValue associated with this object. |
| public Number | Returns: value of the objectOverrides java. Implements javax. Get the value of this object as a Number. |
| public Number | Returns: Maximum value of the object; null if this object does not have a maximum valueOverrides java. Implements javax. Get the maximum value of this object as a Number. |
| public Number | Returns: Minimum value of the object; null if this object does not have a minimum valueOverrides java. Implements javax. Get the minimum value of this object as a Number. |
| public boolean | Returns: true if the value was set; otherwise falseOverrides java. Implements javax. Set the value of this object as a Number. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.3 for interoperability. | |
| AccessibleAWTCheckboxMenuItem | back to summary |
|---|---|
| protected AccessibleAWTCheckboxMenuItem() Constructs an | |
| doAccessibleAction | back to summary |
|---|---|
| public boolean doAccessibleAction(int i) Overrides java. Implements javax. Perform the specified Action on the object
| |
| getAccessibleAction | back to summary |
|---|---|
| public AccessibleAction getAccessibleAction() Overrides java. 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.
| |
| getAccessibleActionCount | back to summary |
|---|---|
| public int getAccessibleActionCount() Overrides java. Implements javax. Returns the number of Actions available in this object. If there is more than one, the first one is the "default" action.
| |
| getAccessibleActionDescription | back to summary |
|---|---|
| public String getAccessibleActionDescription(int i) Overrides java. Implements javax. Return a description of the specified action of the object.
| |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides java. Get the role of this object.
| |
| getAccessibleValue | back to summary |
|---|---|
| public AccessibleValue getAccessibleValue() Overrides java. Get the AccessibleValue associated with this object. In the implementation of the Java Accessibility API for this class, return this object, which is responsible for implementing the AccessibleValue interface on behalf of itself.
| |
| getCurrentAccessibleValue | back to summary |
|---|---|
| public Number getCurrentAccessibleValue() Overrides java. Implements javax. Get the value of this object as a Number. If the value has not been set, the return value will be null.
| |
| getMaximumAccessibleValue | back to summary |
|---|---|
| public Number getMaximumAccessibleValue() Overrides java. Implements javax. Get the maximum value of this object as a Number.
| |
| getMinimumAccessibleValue | back to summary |
|---|---|
| public Number getMinimumAccessibleValue() Overrides java. Implements javax. Get the minimum value of this object as a Number.
| |
| setCurrentAccessibleValue | back to summary |
|---|---|
| public boolean setCurrentAccessibleValue(Number n) Overrides java. Implements javax. Set the value of this object as a Number.
| |