FileDocCategorySizeDatePackage
Counter1.javaAPI DocExample3788Mon Apr 06 18:10:22 BST 1998c14

Counter1

public class Counter1 extends Applet

Fields Summary
private int
count
private Button
onOff
private Button
start
private TextField
t
private boolean
runFlag
Constructors Summary
Methods Summary
public voidgo()

    while (true) {
      try {
        Thread.currentThread().sleep(100);
      } catch (InterruptedException e){}
      if(runFlag) 
        t.setText(Integer.toString(count++));
    }
  
public voidinit()

     
    add(t);
    start.addActionListener(new StartL());
    add(start);
    onOff.addActionListener(new OnOffL());
    add(onOff);
  
public static voidmain(java.lang.String[] args)

    Counter1 applet = new Counter1();
    Frame aFrame = new Frame("Counter1");
    aFrame.addWindowListener(
      new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      });
    aFrame.add(applet, BorderLayout.CENTER);
    aFrame.setSize(300,200);
    applet.init();
    applet.start();
    aFrame.setVisible(true);