Chris Johnson, Index
Radio Buttons and Check Boxes
/*
* Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
/*
* 1.0 and 1.1 version (doenst handle events).
*
* Modified by: Chris Johnson
* johnson@dcs.gla.ac.uk
*
* Date: 21/10/98
*
* The original had two examples of check boxes - a simple panel where
* any could be set from a choice of three and thedio box.
* I simplified things by splitting the example into two.
*/
import java.awt.*;
import java.applet.Applet;
public class SimpleRadioBox extends Applet {
public void init() {
Panel p1;
Checkbox cb1, cb2, cb3; //independent checkboxes
CheckboxGroup cbg;
//Build panel, which contains a checkbox group
cbg = new CheckboxGroup();
cb1 = new Checkbox("Medium Wave", cbg, false);
cb2 = new Checkbox("VHF", cbg, false);
cb3 = new Checkbox("Long Wave", cbg, false);
p1 = new Panel();
p1.setLayout(new FlowLayout());
p1.add(cb1);
p1.add(cb2);
p1.add(cb3);
//Add panels to the Applet. Retained in case we want to add several checkboxes etc
setLayout(new GridLayout(0, 1));
add(p1);
validate();
}
}