1 /* 2 * File: CheckboxDemo.java 3 * 4 * Create some checkboxes 5 * 6 * Copyright: Northeast Parallel Architectures Center 7 * 8 */ 9 10 import java.awt.Color; 11 import java.awt.Checkbox; 12 import java.awt.Panel; 13 14 public class CheckboxDemo extends java.applet.Applet { 15 16 private Checkbox[] box = new Checkbox[5]; 17 18 public void init() { 19 setBackground( Color.white ); 20 Color lightBlue = new Color( 0xB0, 0xE0, 0xE6 ); 21 Color navyBlue = new Color( 0x19, 0x19, 0x70 ); 22 23 // Instantiate some checkboxes: 24 box[0] = new Checkbox( "Shoes" ); 25 box[1] = new Checkbox( "Socks" ); 26 box[2] = new Checkbox( "Pants" ); 27 box[3] = new Checkbox( "Shirt" ); 28 // Check the next box by default: 29 boolean checked = true; 30 box[4] = new Checkbox( "Underwear", checked ); 31 32 // Add checkboxes to a panel and register with applet: 33 Panel checkboxPanel = new Panel(); 34 checkboxPanel.setBackground( lightBlue ); 35 for ( int i = 0; i < box.length; i++ ) { 36 box[i].setForeground( navyBlue ); 37 box[i].setBackground( lightBlue ); 38 checkboxPanel.add( box[i] ); 39 } 40 41 add( checkboxPanel ); 42 43 } 44 45 }