Packages  This Package  Prev  Next  Index  

§1.7 Class CheckboxMenuItem

public  class  java.awt.CheckboxMenuItem
    extends  java.awt.MenuItem  (II-§1.32)
{
        // Constructors
    public CheckboxMenuItem(String  label);	§1.7.1

        // Methods
    public void addNotify();	§1.7.2
    public boolean getState();	§1.7.3
    public String paramString();	§1.7.4
    public void setState(boolean  t);	§1.7.5
}
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 picture of a menu bar (page II-188) shows five menu items. The item labeled Check shows a check box menu item in its "off" state.

When a check box menu item is clicked, the AWT sends an action event (II-§1.14.11) to the check box menu item's containing frame. The event's target is the check box menu item, and its object is the string label of the check box.


Constructors

CheckboxMenuItem

public CheckboxMenuItem(String label)
Creates a check box with the specified label. The check box is initially set to "off".
Parameters:
label - a string label for the check box menu item, or null for an unlabeled menu item

Methods

addNotify

public void addNotify()
This method calls the createCheckboxMenuItem method (II-§1.41.6) of the check box's toolkit (II-§1.10.20) in order to create a CheckboxMenuItemPeer (II-§3.3) for this button. This peer allows the application to change the look of a check box menu item without changing its functionality.


Most applications do not call this method directly.
Overrides:
addNotify in class MenuItem (II-§1.32.2).

getState

public boolean getState()
Determines whether this check box menu item is "on" or "off."
Returns:
the state of this check box menu item: true indicates "on", false indicates "off".

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 (II-§1.32.8).

setState

public void setState(boolean state)
Sets this check box menu item to the specifed boolean state: true indicates "on"; false indicates "off".
Parameters:
state - the boolean state of this check box menu item

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com