import javax.swing.JLabel;

/**
 * @author Dave Matuszek
 * @version Apr 12, 2005
 */
public class Clock extends Thread {
    JLabel display;
    public boolean stopped;
    public boolean paused;
    int count = 0;
    
    public Clock(JLabel display) {
        this.display = display;
    }
    
    public synchronized void run() {
        stopped = false;
        count = 0;
        for (int i = 0; i < 60; i++) {
            if (stopped) break;
            while (paused) {
                try {
                    sleep(100);
                }
                catch (InterruptedException e) { }
            }
            tick();
        }
    }

    private void tick() {
        try {
            display.setText("" + count++);
            Thread.sleep(1000);
            }
        catch (InterruptedException e) { }        
    }

}
