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.


Constructor Index

 o CheckboxMenuItem()
Creates a checkbox menu item with an empty label, initially set to off (false state).
 o CheckboxMenuItem(String)
Creates the checkbox item with the specified label, initially set to off (false state).
 o CheckboxMenuItem(String, boolean)
Creates a checkbox menu item with the specified label and state.

Method Index

 o addItemListener(ItemListener)
Adds the specified item listener to recieve item events from this checkbox menu item.
 o addNotify()
Creates the peer of the checkbox item.
 o getSelectedObjects()
Returns the an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
 o getState()
Returns the state of this MenuItem.
 o paramString()
Returns the parameter String of this button.
 o processEvent(AWTEvent)
Processes events on this checkbox menu item.
 o processItemEvent(ItemEvent)
Processes item events occurring on this checkbox menu item by dispatching them to any registered ItemListener objects.
 o removeItemListener(ItemListener)
Removes the specified item listener so it no longer receives item events from this checkbox menu item.
 o setState(boolean)
Sets the state of this MenuItem if it is a Checkbox.

Constructors

 o CheckboxMenuItem
 public CheckboxMenuItem()
Creates a checkbox menu item with an empty label, initially set to off (false state).

 o CheckboxMenuItem
 public CheckboxMenuItem(String label)
Creates the checkbox item with the specified label, initially set to off (false state).

Parameters:
label - the button label
 o 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".

Methods

 o 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
 o getState
 public boolean getState()
Returns the state of this MenuItem. This method is only valid for a Checkbox.

 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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