Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • If you try to access any page and it says "You do not have permission," do not hesitate to contact us you just need to upgrade your account to either VIP or Premium in order to access that page. Click here to upgrade your account
    Contact us for MTN mobile money payment Contact us here

How To Create Digital Clock & Date

koukei

Moderator
Joined
Nov 17, 2018
Messages
41
import java.awt.Graphics;

import java.awt.Font;

import java.util.Date;

public class DigitalClock extends java.applet.Applet {

Font theFont = new Font(“TimesRoman”,Font.BOLD,24);

Date theDate;

public void start() {

while (true) {

theDate = new Date();

repaint();

try { Thread.sleep(1000); }

catch (InterruptedException e) { }

}

}

public void paint(Graphics g) {

g.setFont(theFont);

g.drawString(theDate.toString(),10,50);

}

}
 
Top