Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class CheckboxGroup

Constructors , Methods

public  class  java.awt.CheckboxGroup
    extends  java.lang.Object  
{
        // Constructors
    public CheckboxGroup();	

        // Methods
    public Checkbox getCurrent();	
    public void setCurrent(Checkbox  box);	
    public String toString();	
}

This class is used to group together a set of Checkbox buttons.

Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time. Pushing any button turns it "on" and forces any other button that is "on" to become "off".

For example, the code:


	setLayout(new GridLayout(3, 1));
CheckboxGroup cbg = new CheckboxGroup();
add(new Checkbox("one",   cbg, true));
add(new Checkbox("two",   cbg, false));
add(new Checkbox("three", cbg, false));


produces the following three check boxes:

When a check box in a check box group is clicked, AWT sends an action event to that check box. This event's target is the check box, and its object is a value equal to Boolean.TRUE . No action event is sent to the check box (if any) that is turned off. An application should override the action method of the check box or of one of its parent containers in order to cause some action to occur.


Constructors


CheckboxGroup

public CheckboxGroup() 

Creates a new CheckboxGroup.


Methods


getCurrent

public Checkbox getCurrent() 

Return Value:

Returns the check box in this check box group that is currently "on", or null if all are "off".


setCurrent

public void setCurrent(Checkbox  box) 

If the indicated check box argument belongs to this check box group, this method sets that check box to be "on", and all other checkboxes in this group to be "off"

If the check box argument is null or belongs to a different check box group, then this method does nothing.

ParameterDescription
box the Checkbox to set "on"


toString

public String toString() 

Return Value:

Returns a string representation of this check box group.

Overrides:

toString in class Object .



Top© 1996 Sun Microsystems, Inc. All rights reserved.