Basic HTML version of Foils prepared 13 October 97

Foil 37 AWT Components -- Checkbox

From Java Tutorial, July 1, 1996 CSC499(JSU) CPS406/606 -- Fall Semester 97. by Nancy J. McCracken,Geoffrey C. Fox

Checkboxes for Foil 37
Checkboxes are on-off toggles implemented as
Checkbox red = new Checkbox("Red");
Checkbox green = new Checkbox("Green");
Checkbox blue = new Checkbox("Blue",null, true);
add(red); add(green); add(blue);
The first two are initially set to "false" as the optional third argument is not given. The last one is initially set to "true".
The state of a checkbox, i.e. whether it is checked, is given by a boolean result of the method, getState:
    • if (red.getState()) . . .;
If a user clicks a Checkbox, an ItemEvent is generated. The listener must implement ItemListener with the one method itemStateChanged (ItemEvent e).



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998