java.lang.Object | +--java.awt.MenuComponent | +--java.awt.MenuItem | +--java.awt.CheckboxMenuItem
Unsafe:
CheckboxMenuItem()
CheckboxMenuItem(String label)
CheckboxMenuItem(String label,
boolean state)
void
addItemListener(ItemListener l)
AccessibleContext
getAccessibleContext()
ItemListener[]
getItemListeners()
EventListener[]
getListeners(Class listenerType)
FooListeners
upon this CheckboxMenuItem.
Object[]
getSelectedObjects()
boolean
getState()
protected void
processItemEvent(ItemEvent e)
ItemListener objects.
private void
readObject(ObjectInputStream s)
ObjectInputStream and if it
isn't null adds a listener to receive
action events fired by the Menu Item.
void
removeItemListener(ItemListener l)
addActionListener, deleteShortcut, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getActionCommand, getActionListeners, getLabel, getShortcut, getShortcutMenuItem, handleShortcut, isEnabled, processActionEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcut
dispatchEvent, dispatchEventImpl, getAccessibleIndexInParent, getAccessibleStateSet, getFont_NoClientCode, getFont, getName, getParent_NoClientCode, getParent, getPeer, getTreeLock, postEvent, removeNotify, setFont, setName, toString
boolean state
getState(),
#setState()transient ItemListener itemListener
private static final String base
private static int nameCounter
private static final long serialVersionUID
private int checkboxMenuItemSerializedDataVersion
public CheckboxMenuItem() throws HeadlessException
java.awt.GraphicsEnvironment#isHeadlesspublic CheckboxMenuItem(String label) throws HeadlessException
label - a string label for the check box menu item,
or null for an unlabeled menu item.java.awt.GraphicsEnvironment#isHeadlesspublic CheckboxMenuItem(String label, boolean state) throws HeadlessException
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."java.awt.GraphicsEnvironment#isHeadlessString constructComponentName()
constructComponentName in class MenuItemMenuComponentpublic void addNotify()
java.awt.Toolkit#createCheckboxMenuItem(java.awt.CheckboxMenuItem),
java.awt.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."
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 ItemEvent. The only way to trigger an
ItemEvent is by user interaction.
b - true if the check box
menu item is on, otherwise falsegetState()public Object[] getSelectedObjects()
getSelectedObjects in interface ItemSelectableItemSelectablepublic void addItemListener(ItemListener l)
addItemListener in interface ItemSelectablel - the item listenerremoveItemListener(java.awt.event.ItemListener),
getItemListeners(),
setState(boolean),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic void removeItemListener(ItemListener l)
removeItemListener in interface ItemSelectablel - the item listeneraddItemListener(java.awt.event.ItemListener),
getItemListeners(),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic ItemListener[] getItemListeners()
ItemListeners
or an empty array if no item
listeners are currently registeredaddItemListener(java.awt.event.ItemListener),
removeItemListener(java.awt.event.ItemListener),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic EventListener[] getListeners(Class listenerType)
FooListeners
upon this CheckboxMenuItem.
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
CheckboxMenuItem 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.
getListeners in class MenuItemlistenerType - the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListeners on this checkbox menuitem,
or an empty array if no such
listeners have been addedgetItemListeners()boolean eventEnabled(AWTEvent e)
eventEnabled in class MenuItemprotected 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.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processEvent in class MenuIteme - the eventjava.awt.event.ItemEvent,
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.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
e - the item eventjava.awt.event.ItemEvent,
java.awt.event.ItemListener,
addItemListener(java.awt.event.ItemListener),
java.awt.MenuItem#enableEventsvoid doMenuEvent(long when, int modifiers)
doMenuEvent in class MenuItempublic String paramString()
CheckBoxMenuItem. 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.
paramString in class MenuItemprivate void writeObject(ObjectOutputStream s) throws IOException
ItemListeners
as optional data. The non-serializable
ItemListeners are detected and
no attempt is made to serialize them.
s - the ObjectOutputStream to write
IOExceptionAWTEventMulticaster.save(ObjectOutputStream, String, EventListener),
java.awt.Component.itemListenerK,
readObject(java.io.ObjectInputStream)private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
MenuItemObjectInputStream and if it
isn't null adds a listener to receive
action events fired by the Menu Item.
Unrecognized keys or values will be ignored.
s - the ObjectInputStream to read
ClassNotFoundException
IOExceptionremoveActionListener(),
addActionListener(),
MenuItem.writeObject(java.io.ObjectOutputStream)private static void initIDs()
public AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class MenuItem