Java Clock Tutorial

Published: 11 April 2015
on channel: Java Tutorials For Beginners
1,842
0

A Not exactly simple video on how to make a clock in eclipse. It was in halves because I'd made it before, but I needed it with me. So I had 2 eclipse windows open.
Source Code:import java.awt.*;
import java.applet.*;

import java.applet.*;
import java.awt.*;
import java.util.*;

public class Simple_Clock extends Applet implements Runnable {
Thread t, t1;
public void start() {
t = new Thread (this);
t.start();
}

public void run (){
t1 = Thread.currentThread();
while(t1 == t){
repaint();
try{
t1.sleep(1000);
}
catch(InterruptedException e) {}
}
}
public void paint(Graphics g) {
Calendar cal = new GregorianCalendar();
String hour = String.valueOf(cal.get(Calendar.HOUR));
String minute = String.valueOf(cal.get(Calendar.MINUTE));
String second = String.valueOf(cal.get(Calendar.SECOND));
g.drawString(hour + ":" + minute + ":" + second, 20 ,30);
}
}
//It Works :D


On this page of the site you can watch the video online Java Clock Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Java Tutorials For Beginners 11 April 2015, share the link with friends and acquaintances, this video has already been watched 1,842 times on youtube and it was liked by 0 viewers. Enjoy your viewing!