Show System Date and Time in JFrame ( Dynamic Clock )
Java 2016
public void clock(){
Thread clock = new Thread(){
public void run(){
try {
while(true){
Calendar cal = new GregorianCalendar();
int second = cal.get(Calendar.SECOND);
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
lblTime.setText(hour +":"+ minute +":"+ second);
sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
clock.start();
}
0 nhận xét:
Post a Comment