Clock Applet (continued)
public void paint(Graphics g) {
g.drawString("The time is: " +
(new Date()), 100, 50);
}
public void run() {
while (true) {
try { Thread.sleep(1000); }
catch (InterruptedException e) {
if (timeThread.timeToQuit) return; }
repaint();
}
}
public void start() {}
public void stop() {}
public void destroy() {
timeThread.timeToQuit = true;
timeThread.interrupt(); }
}
Previous slide
Next slide
Back to first slide
View graphic version