//********************************************************************* //* Programmer : Jang Kyu-O(Àå ±Ô¿À) * //* Date : 1996/2/10 * //* E-Mail : kojang@ctkhost.ctk.co.kr * //* Tel : +82-02-3149-4821 * //* Address : Á¦À̾¾Çö ¿¤¸²³×Æ®»ç¾÷º»ºÎ À¥ÆÀ * //********************************************************************* import java.applet.*; import java.awt.*; import java.util.Date; public class Clock extends java.applet.Applet implements Runnable { Thread clockThread; Color c[]; int numc; int count; public void init() { numc = 9; c = new Color[numc]; c[0] = new Color(200+40, 130+40, 100+40); c[1] = new Color(200+30, 130+30, 100+30); c[2] = new Color(200+20, 130+20, 100+20); c[3] = new Color(200+10, 130+10, 100+10); c[4] = new Color(200, 130, 100); c[5] = new Color(200-10, 130-10, 100-10); c[6] = new Color(200-20, 130-20, 100-20); c[7] = new Color(200-30, 130-30, 100-30); c[8] = new Color(200-40, 130-40, 100-40); count=0; } public void start() { if (clockThread == null) { clockThread = new Thread(this, "Clock"); clockThread.start(); } } public void run() { while (clockThread != null) { repaint(); count++; count %= numc; try { clockThread.sleep(1000); } catch (InterruptedException e){ } } } public void paint(Graphics g) { Rectangle r = bounds(); g.setColor(Color.white); g.fillRect(0, 0, r.width, r.height/2); Date now = new Date(); g.setFont(new Font("Helvista", 1, 20)); g.setColor(c[count]); g.drawString(now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(), 15, r.height/4); update(g); } public void update(Graphics g) { Rectangle r = bounds(); g.setColor(Color.darkGray); g.fillRect(0, r.height/2, r.width, r.height/2); Date now = new Date(); g.setFont(new Font("Helvista", 1, 20)); g.setColor(c[count]); g.drawString(now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(), 15, r.height/4*3); } public void stop() { clockThread.stop(); clockThread = null; } }