|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.MenuComponent | +--java.awt.MenuItem | +--java.awt.CheckboxMenuItem
Unsafe:
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
The state of a checkbox menu item |
Fields inherited from class java.awt.MenuItem |
actionCommand, actionListener, enabled, eventMask, label |
Fields inherited from class java.awt.MenuComponent |
accessibleContext, actionListenerK, appContext, font, itemListenerK, newEventsOnly, parent, peer |
Constructor Summary | |
CheckboxMenuItem()
Suppressed: Create a check box menu item with an empty label. |
|
CheckboxMenuItem(String label)
Suppressed: Create a check box menu item with the specified label. |
|
CheckboxMenuItem(String label,
boolean state)
Suppressed: Create a check box menu item with the specified label and state. |
Method Summary | |
void |
addItemListener(ItemListener l)
Suppressed: Adds the specified item listener to receive item events from this check box menu item. |
void |
addNotify()
Suppressed: Creates the peer of the checkbox item. |
(package private) String |
constructComponentName()
Construct a name for this MenuComponent. |
(package private) void |
doMenuEvent(long when,
int modifiers)
|
(package private) boolean |
eventEnabled(AWTEvent e)
|
AccessibleContext |
getAccessibleContext()
Suppressed: Gets the AccessibleContext associated with this CheckboxMenuItem. |
ItemListener[] |
getItemListeners()
Suppressed: Returns an array of all the item listeners registered on this checkbox menuitem. |
EventListener[] |
getListeners(Class listenerType)
Suppressed: Returns an array of all the objects currently registered as FooListener s
upon this CheckboxMenuItem . |
Object[] |
getSelectedObjects()
Suppressed: Returns the an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected. |
boolean |
getState()
Suppressed: 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()
Suppressed: Returns a string representing the state of this CheckBoxMenuItem . |
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)
Reads the ObjectInputStream and if it
isn't null adds a listener to receive
action events fired by the Menu Item. |
void |
removeItemListener(ItemListener l)
Suppressed: Removes the specified item listener so that it no longer receives item events from this check box menu item. |
void |
setState(boolean b)
Suppressed: 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, getActionListeners, getLabel, getShortcut, getShortcutMenuItem, handleShortcut, isEnabled, processActionEvent, removeActionListener, setActionCommand, setEnabled, setLabel, setShortcut |
Methods inherited from class java.awt.MenuComponent |
dispatchEvent, dispatchEventImpl, getAccessibleIndexInParent, getAccessibleStateSet, 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, wait, wait, wait |
Field Detail |
boolean state
getState()
,
#setState()
transient ItemListener itemListener
private static final String base
private static int nameCounter
private static final long serialVersionUID
private int checkboxMenuItemSerializedDataVersion
Constructor Detail |
public CheckboxMenuItem() throws HeadlessException
java.awt.GraphicsEnvironment#isHeadless
public 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#isHeadless
public 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#isHeadless
Method Detail |
String constructComponentName()
constructComponentName
in class MenuItem
MenuComponent
public void addNotify()
addNotify
in class MenuItem
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 false
getState()
public Object[] getSelectedObjects()
getSelectedObjects
in interface ItemSelectable
ItemSelectable
public void addItemListener(ItemListener l)
addItemListener
in interface ItemSelectable
l
- the item listenerremoveItemListener(java.awt.event.ItemListener)
,
getItemListeners()
,
setState(boolean)
,
java.awt.event.ItemEvent
,
java.awt.event.ItemListener
public void removeItemListener(ItemListener l)
removeItemListener
in interface ItemSelectable
l
- the item listeneraddItemListener(java.awt.event.ItemListener)
,
getItemListeners()
,
java.awt.event.ItemEvent
,
java.awt.event.ItemListener
public ItemListener[] getItemListeners()
ItemListener
s
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.ItemListener
public EventListener[] getListeners(Class listenerType)
FooListener
s
upon this CheckboxMenuItem
.
FooListener
s 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 MenuItem
listenerType
- the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListener
s on this checkbox menuitem,
or an empty array if no such
listeners have been addedgetItemListeners()
boolean eventEnabled(AWTEvent e)
eventEnabled
in class MenuItem
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.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processEvent
in class MenuItem
e
- 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#enableEvents
void doMenuEvent(long when, int modifiers)
doMenuEvent
in class MenuItem
public 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 MenuItem
private 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
IOException
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener)
,
java.awt.Component.itemListenerK
,
readObject(java.io.ObjectInputStream)
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
MenuItem
ObjectInputStream
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
IOException
removeActionListener()
,
addActionListener()
,
MenuItem.writeObject(java.io.ObjectOutputStream)
private static void initIDs()
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class MenuItem
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |