1 | public void run () { |
2 | while (clockThread !=null) { |
3 | repaint (); |
4 |
try { clockThread.sleep(1000);
|
5 | } // end while |
6 | } // end run() |
7 | public void paint (Graphics g) { |
8 | Date now = new Date (); |
9 | g.drawString (now.getHours() + ":"+ now.getMinutes() + ":"+now.getSeconds(), 5, 10); |
10 | } |
11 | public void stop () { |
12 | clockThread.stop(); |
13 | clockThread = null; |
14 | } |
15 | } // End Digital Clock Applet |