FileDocCategorySizeDatePackage
Counter3.javaAPI DocExample3972Mon Apr 06 18:10:22 BST 1998None

Counter3

public class Counter3 extends Applet implements Runnable

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

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

    Counter3 applet = new Counter3();
    Frame aFrame = new Frame("Counter3");
    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);
  
public voidrun()

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