Basic HTML version of Foils prepared Sept 21 1998

Foil 38 AWT Components -- Radio Buttons , CheckboxGroup

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

 for Foil 38
Radio buttons are identical to Checkboxes but grouped so that only one checkbox in a group can be on at a time. They use same class for checkboxes, but add CheckboxGroup class.
  • CheckboxGroup cbg = new CheckboxGroup();
  • cb1 = new Checkbox("Red", cbg, false));
  • cb2 = new Checkbox("Green", cbg, false));
  • cb3 = new Checkbox("Blue", cbg, true));
  • add(cb1); add(cb2); add(cb3);
In addition to checking the state of checkboxes in a group, there is a method to return the one checkbox which is on:
  • cb = cbg.getSelectedCheckbox();



© 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 Sat Nov 28 1998