Packages  This Package  Prev  Next  Index  

§1.6 Class CheckboxGroup

public  class  java.awt.CheckboxGroup
    extends  java.lang.Object  (I-§1.12)
{
        // Constructors
    public CheckboxGroup();	§1.6.1

        // Methods
    public Checkbox getCurrent();	§1.6.2
    public void setCurrent(Checkbox  box);	§1.6.3
    public String toString();	§1.6.4
}
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 (II-§1.14.11) to that check box. This event's target is the check box, and its object is a value equal to Boolean.TRUE (I-§1.1.2). No action event is sent to the check box (if any) that is turned off. An application should override the action method (II-§1.10.1) 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()
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.
Parameters:
box - the Checkbox to set "on"

toString

public String toString()
Returns:
a string representation of this check box group.
Overrides:
toString in class Object (I-§1.12.9).

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