// Demonstrate check boxes.
import java.awt.*;
import java.applet.*;

public class CheckboxDemo extends Applet {
  String msg = "";
  Checkbox win95, winNT, solaris, mac;

  public void init() {
    win95 = new Checkbox("Windows 95", null, true);
    winNT = new Checkbox("Windows NT");
    solaris = new Checkbox("Solaris");
    mac = new Checkbox("MacOS");

    add(win95);
    add(winNT);
    add(solaris);
    add(mac);
  }

  // Repaint when status of check box changes. 
  public boolean action(Event evtObj, Object arg) {
    if(evtObj.target instanceof Checkbox) {
      repaint();
      return true;
    }
    return false;
  }

  // Display current state of the check boxes.
  public void paint(Graphics g) {
    msg = "Current state: ";
    g.drawString(msg, 6, 80);
    msg = "  Windows 95: " + win95.getState();
    g.drawString(msg, 6, 100);
    msg = "  Windows NT: " + winNT.getState();
    g.drawString(msg, 6, 120);
    msg = "  Solaris: " + solaris.getState();
    g.drawString(msg, 6, 140);
    msg = "  MacOS: " + mac.getState();    
    g.drawString(msg, 6, 160);
  }
}