/* Digital Clock*/ import java.awt.*; import java.applet.*; import java.util.*; /* <applet code="DigitalClock" height=700 width=600> </applet */ public class DigitalClock extends Applet implements Runnable { Date date; Font font=new Font("Arial",Font.BOLD,50); public void init() { setBackground(Color.BLACK); setSize(1000,300); } public void start() { Thread th=new Thread(this); th.start(); } public void run() { while(true) { try { Thread.sleep(10); } catch(Exception e){}; date=new Date(); repaint(); } } public void paint(Graphics g) { g.setFont(font); g.setColor(Color.WHITE); g.drawString(date.toString(),60,150); } }
Search Here
Java program for creating Digital clock
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment