/* by Neng-Fa Zhou, May 2003 */ /*
*/ import java.awt.*; import java.applet.Applet; import java.util.*; public class DigitClock extends Applet { GregorianCalendar gc; public void init(){ } public void paint(Graphics g){ int hour, minute, second; Font f = new Font("TimesRoman",Font.BOLD,60); g.setFont(f); while (true){ gc = new GregorianCalendar(); hour = gc.get(Calendar.HOUR); minute = gc.get(Calendar.MINUTE); second = gc.get(Calendar.SECOND); g.setColor(getBackground()); g.fillRect(0,0,getWidth(),getHeight()); g.setColor(Color.black); g.drawString(hour+":"+minute+":"+second,100,100); try { Thread.sleep(1000); } catch (InterruptedException e){}; } } public static void main(String[] args){ DigitClock dc = new DigitClock(); Frame f = new Frame(); f.add(dc); f.setSize(500,500); f.show(); } }