FileDocCategorySizeDatePackage
ClockApplet.javaAPI DocExample766Wed Mar 31 23:43:04 BST 1999None

ClockApplet

public class ClockApplet extends Applet implements Runnable

Fields Summary
Thread
timerThread
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

		Date d = new Date();
		g.drawString(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(), 1, 10);
	
public voidrun()

		while (timerThread != null) {
			repaint();	// request a redraw
			try {
				timerThread.sleep(1000);
			} catch (InterruptedException e){ /* do nothing*/ }
		}
	
public voidstart()

		timerThread = new Thread(this, "Clock");
		timerThread.start();
	
public voidstop()

		if (timerThread == null)
			return;
		timerThread.stop();
		timerThread = null;