当前页面: 
在线文档首页 > 
JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
Class java.awt.CheckboxMenuItem - JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
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 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.
    -  See Also:
    
-  ItemEvent, ItemListener
   
  -   CheckboxMenuItem() CheckboxMenuItem()
-   Create a check box menu item with an empty label.
  
-   CheckboxMenuItem(String) CheckboxMenuItem(String)
-   Create a check box menu item with the specified label.
  
-   CheckboxMenuItem(String, boolean) CheckboxMenuItem(String, boolean)
-   Create a check box menu item with the specified label and state.
   
  -   addItemListener(ItemListener) addItemListener(ItemListener)
-   Adds the specified item listener to receive item events from
 this check box menu item.
  
-   addNotify() addNotify()
-   Creates the peer of the checkbox item.
  
-   getSelectedObjects() getSelectedObjects()
-   Returns the an array (length 1) containing the checkbox menu item
 label or null if the checkbox is not selected.
  
-   getState() getState()
-   Determines whether the state of this check box menu item 
 is "on" or "off." 
 
  
-   paramString() paramString()
-   Returns the parameter string representing the state of this check 
 box menu item.
  
-   processEvent(AWTEvent) processEvent(AWTEvent)
-   Processes events on this check box menu item.
  
-   processItemEvent(ItemEvent) processItemEvent(ItemEvent)
-  
 Processes item events occurring on this check box menu item by
 dispatching them to any registered ItemListenerobjects.
-   removeItemListener(ItemListener) removeItemListener(ItemListener)
-   Removes the specified item listener so that it no longer receives
 item events from this check box menu item.
  
-   setState(boolean) setState(boolean)
-   Sets this check box menu item to the specifed state.
   
 CheckboxMenuItem
CheckboxMenuItem
 public CheckboxMenuItem()
  -  Create a check box menu item with an empty label.
 The item's state is initially set to "off."
 
 CheckboxMenuItem
CheckboxMenuItem
 public CheckboxMenuItem(String label)
  -  Create a check box menu item with the specified label. 
 The item's state is initially set to "off."
   
- 
    -  Parameters:
    
-  label - a string label for the check box menu item,
                or nullfor an unlabeled menu item.
 
 CheckboxMenuItem
CheckboxMenuItem
 public CheckboxMenuItem(String label,
                         boolean state)
  -  Create a check box menu item with the specified label and state.
   
- 
    -  Parameters:
    
-  label - the button label.
    -  state - the initial state of the menu item, where
                     trueindicates "on" andfalseindicates "off."
 
   
 addNotify
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.
 Most applications do not call this method directly.
   
- 
    -  Overrides:
    
-  addNotify in class MenuItem
    
-  See Also:
    
-  createCheckboxMenuItem, getToolkit
  
 
 getState
getState
 public boolean getState()
  -  Determines whether the state of this check box menu item 
 is "on" or "off."
   
- 
    -  Returns:
    
-  the state of this check box menu item, where
                     trueindicates "on" andfalseindicates "off."
-  See Also:
    
-  setState
  
 
 setState
setState
 public synchronized void setState(boolean b)
  -  Sets this check box menu item to the specifed state.
 The boolean value trueindicates "on" whilefalseindicates "off."
   
- 
    -  Parameters:
    
-  b - the boolean state of this
                      check box menu item.
    
-  See Also:
    
-  getState
  
 
 getSelectedObjects
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
addItemListener
 public synchronized void addItemListener(ItemListener l)
  -  Adds the specified item listener to receive item events from
 this check box menu item.
   
- 
    -  Parameters:
    
-  l - the item listener.
    
-  See Also:
    
-  ItemEvent, ItemListener, removeItemListener
  
 
 removeItemListener
removeItemListener
 public synchronized void removeItemListener(ItemListener l)
  -  Removes the specified item listener so that it no longer receives
 item events from this check box menu item.
   
- 
    -  Parameters:
    
-  l - the item listener.
    
-  See Also:
    
-  ItemEvent, ItemListener, addItemListener
  
 
 processEvent
processEvent
 protected void processEvent(AWTEvent e)
  -  Processes events on this check box menu item. 
 If the event is an instance of ItemEvent, 
 this method invokes theprocessItemEventmethod.
 If the event is not an item event,
 it invokesprocessEventon the superclass.
 Check box menu items currently support only item events.
 
   
- 
    -  Parameters:
    
-  e - the event
    
-  Overrides:
    
-  processEvent in class MenuItem
    
-  See Also:
    
-  ItemEvent, processItemEvent
  
 
 processItemEvent
processItemEvent
 protected void processItemEvent(ItemEvent e)
  -  Processes item events occurring on this check box menu item by
 dispatching them to any registered ItemListenerobjects.
 This method is not called unless item events are 
 enabled for this menu item. Item events are enabled 
 when one of the following occurs:
  
 - An ItemListenerobject is registered 
 viaaddItemListener.
- Item events are enabled via enableEvents.
 
   
- 
    -  Parameters:
    
-  e - the item event.
    
-  See Also:
    
-  ItemEvent, ItemListener, addItemListener, enableEvents
  
 
 paramString
paramString
 public String paramString()
  -  Returns the parameter string representing the state of this check 
 box menu item. This string is useful for debugging.
   
- 
    -  Returns:
    
-  the parameter string of this check box menu item.
    
-  Overrides:
    
-  paramString in class MenuItem
  
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems,  Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A.  All Rights Reserved.