All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.CheckboxMenuItem
java.lang.Object
|
+----java.awt.MenuComponent
|
+----java.awt.MenuItem
|
+----java.awt.CheckboxMenuItem
- public class CheckboxMenuItem
- extends MenuItem
- implements ItemSelectable
This class produces a checkbox that represents a choice in a menu.
-
CheckboxMenuItem()
- Creates a checkbox menu item with an empty label, initially set
to off (false state).
-
CheckboxMenuItem(String)
- Creates the checkbox item with the specified label, initially
set to off (false state).
-
CheckboxMenuItem(String, boolean)
- Creates a checkbox menu item with the specified label and state.
-
addItemListener(ItemListener)
- Adds the specified item listener to recieve item events from
this checkbox menu item.
-
addNotify()
- Creates the peer of the checkbox item.
-
getSelectedObjects()
- Returns the an array (length 1) containing the checkbox menu item
label or null if the checkbox is not selected.
-
getState()
- Returns the state of this MenuItem.
-
paramString()
- Returns the parameter String of this button.
-
processEvent(AWTEvent)
- Processes events on this checkbox menu item.
-
processItemEvent(ItemEvent)
-
Processes item events occurring on this checkbox menu item by
dispatching them to any registered ItemListener objects.
-
removeItemListener(ItemListener)
- Removes the specified item listener so it no longer receives
item events from this checkbox menu item.
-
setState(boolean)
- Sets the state of this MenuItem if it is a Checkbox.
CheckboxMenuItem
public CheckboxMenuItem()
- Creates a checkbox menu item with an empty label, initially set
to off (false state).
CheckboxMenuItem
public CheckboxMenuItem(String label)
- Creates the checkbox item with the specified label, initially
set to off (false state).
- Parameters:
- label - the button label
CheckboxMenuItem
public CheckboxMenuItem(String label,
boolean state)
- Creates a checkbox menu item with the specified label and state.
- Parameters:
- label - the button label
- state - the initial state of the menu item: true
indicates "on"; false indicates "off".
addNotify
public void addNotify()
- Creates the peer of the checkbox item. This peer allows us to
change the look of the checkbox item without changing its
functionality.
- Overrides:
- addNotify in class MenuItem
getState
public boolean getState()
- Returns the state of this MenuItem. This method is only valid for a
Checkbox.
setState
public synchronized void setState(boolean b)
- Sets the state of this MenuItem if it is a Checkbox.
- Parameters:
- t - the specified state of the checkbox
getSelectedObjects
public synchronized Object[] getSelectedObjects()
- Returns the an array (length 1) containing the checkbox menu item
label or null if the checkbox is not selected.
- See Also:
- ItemSelectable
addItemListener
public synchronized void addItemListener(ItemListener l)
- Adds the specified item listener to recieve item events from
this checkbox menu item.
- Parameters:
- l - the item listener
removeItemListener
public synchronized void removeItemListener(ItemListener l)
- Removes the specified item listener so it no longer receives
item events from this checkbox menu item.
- Parameters:
- l - the item listener
processEvent
protected void processEvent(AWTEvent e)
- Processes events on this checkbox menu item. If the event is
an ItemEvent, it invokes the handleItemEvent method.
NOTE: Checkbox menu items currently only support action and
item events.
- Parameters:
- e - the event
- Overrides:
- processEvent in class MenuItem
processItemEvent
protected void processItemEvent(ItemEvent e)
- Processes item events occurring on this checkbox menu item by
dispatching them to any registered ItemListener objects.
NOTE: This method will not be called unless item events
are enabled for this checkbox menu item; this happens when one of the
following occurs:
a) An ItemListener object is registered via addItemListener()
b) Item events are enabled via enableEvents()
- Parameters:
- e - the item event
- See Also:
- enableEvents
paramString
public String paramString()
- Returns the parameter String of this button.
- Overrides:
- paramString in class MenuItem
All Packages Class Hierarchy This Package Previous Next Index