CheckboxGroup

A CheckboxGroup is used to control the behavior of a group of Checkbox objects (each of which has state true or false). Exactly one of the Checkbox objects is allowed to be true at one time. Checkbox objects controlled with a CheckboxGroup are sometimes called "radio" buttons. The following example illustrates the basic idea behind radio buttons.



Corresponding source code:

import java.applet.*;
import java.awt.*;
public class CheckboxGroupWidget extends Applet {
    public void init() {
        // create button controller
        CheckboxGroup cbg = new CheckboxGroup();
        Checkbox cb1;
        cb1 = new Checkbox("Show lowercase only",cbg,true);
        Checkbox cb2;
        cb2 = new Checkbox("Show uppercase only",cbg,false);
        add(cb1);
        add(cb2);
    }
}

Related Magercise(s):