|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.MenuComponent
|
+--java.awt.MenuItem
|
+--java.awt.CheckboxMenuItem
This class represents a check box that can be included in a menu. Clicking on the check box in the menu changes its state from "on" to "off" or from "off" to "on."
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.
ItemEvent,
ItemListener, Serialized Form| Field Summary | |
private static String |
base
|
private int |
checkboxMenuItemSerializedDataVersion
|
(package private) ItemListener |
itemListener
|
private static int |
nameCounter
|
private static long |
serialVersionUID
|
(package private) boolean |
state
|
| Fields inherited from class java.awt.MenuItem |
actionCommand,
actionListener,
base,
enabled,
eventMask,
label,
menuItemSerializedDataVersion,
nameCounter,
serialVersionUID,
shortcut |
| Fields inherited from class java.awt.MenuComponent |
actionListenerK,
appContext,
font,
itemListenerK,
name,
nameExplicitlySet,
newEventsOnly,
parent,
peer,
serialVersionUID |
| Constructor Summary | |
CheckboxMenuItem()
Create a check box menu item with an empty label. |
|
CheckboxMenuItem(String label)
Create a check box menu item with the specified label. |
|
CheckboxMenuItem(String label,
boolean state)
Create a check box menu item with the specified label and state. |
|
| Method Summary | |
(package private) static void |
|
void |
addItemListener(ItemListener l)
Adds the specified item listener to receive item events from this check box menu item. |
void |
addNotify()
Creates the peer of the checkbox item. |
(package private) String |
constructComponentName()
Construct a name for this MenuComponent. |
(package private) boolean |
eventEnabled(AWTEvent e)
|
Object[] |
getSelectedObjects()
Returns the an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected. |
boolean |
getState()
Determines whether the state of this check box menu item is "on" or "off." |
private static void |
initIDs()
Initialize JNI field and method IDs |
String |
paramString()
Returns the parameter string representing the state of this check box menu item. |
protected void |
processEvent(AWTEvent e)
Processes events on this check box menu item. |
protected void |
processItemEvent(ItemEvent e)
Processes item events occurring on this check box menu item by dispatching them to any registered ItemListener objects. |
private void |
readObject(ObjectInputStream s)
|
void |
removeItemListener(ItemListener l)
Removes the specified item listener so that it no longer receives item events from this check box menu item. |
void |
setState(boolean b)
Sets this check box menu item to the specifed state. |
private void |
writeObject(ObjectOutputStream s)
Writes default serializable fields to stream. |
| Methods inherited from class java.awt.MenuItem |
addActionListener,
deleteShortcut,
deleteShortcut,
disable,
disableEvents,
enable,
enable,
enableEvents,
getActionCommand,
getLabel,
getShortcut,
getShortcutMenuItem,
handleShortcut,
isEnabled,
processActionEvent,
removeActionListener,
setActionCommand,
setEnabled,
setLabel,
setShortcut |
| Methods inherited from class java.awt.MenuComponent |
dispatchEvent,
dispatchEventImpl,
getFont_NoClientCode,
getFont,
getName,
getParent_NoClientCode,
getParent,
getPeer,
getTreeLock,
postEvent,
removeNotify,
setFont,
setName,
toString |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
| Field Detail |
boolean state
transient ItemListener itemListener
private static final String base
private static int nameCounter
private static final long serialVersionUID
private int checkboxMenuItemSerializedDataVersion
| Constructor Detail |
public CheckboxMenuItem()
public CheckboxMenuItem(String label)
label - a string label for the check box menu item,
or null for an unlabeled menu item.
public CheckboxMenuItem(String label,
boolean state)
label - a string label for the check box menu item,
or null for an unlabeled menu item.state - the initial state of the menu item, where
true indicates "on" and
false indicates "off."| Method Detail |
static void()
String constructComponentName()
public void addNotify()
Toolkit.createCheckboxMenuItem(java.awt.CheckboxMenuItem),
Component.getToolkit()public boolean getState()
true indicates "on" and
false indicates "off."setState(boolean)public void setState(boolean b)
true indicates "on" while
false indicates "off."b - the boolean state of this
check box menu item.getState()public Object[] getSelectedObjects()
ItemSelectablepublic void addItemListener(ItemListener l)
l - the item listenerItemEvent,
ItemListener,
Choice.removeItemListener(java.awt.event.ItemListener)public void removeItemListener(ItemListener l)
l - the item listenerItemEvent,
ItemListener,
Choice.addItemListener(java.awt.event.ItemListener)boolean eventEnabled(AWTEvent e)
protected void processEvent(AWTEvent e)
ItemEvent,
this method invokes the processItemEvent method.
If the event is not an item event,
it invokes processEvent on the superclass.
Check box menu items currently support only item events.
e - the eventItemEvent,
processItemEvent(java.awt.event.ItemEvent)protected void processItemEvent(ItemEvent e)
ItemListener objects.
This method is not called unless item events are enabled for this menu item. Item events are enabled when one of the following occurs:
ItemListener object is registered
via addItemListener.
enableEvents.
e - the item event.ItemEvent,
ItemListener,
addItemListener(java.awt.event.ItemListener),
MenuItem.enableEvents(long)public String paramString()
private void writeObject(ObjectOutputStream s)
throws IOException
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener),
java.awt.Component.itemListenerK
private void readObject(ObjectInputStream s)
throws ClassNotFoundException,
IOException
private static void initIDs()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||