0% found this document useful (0 votes)
19 views1 page

DigitalWatch Awt

Uploaded by

sirishaksnlp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

DigitalWatch Awt

Uploaded by

sirishaksnlp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import javax.swing.

*;
import java.awt.*;
import java.text.*;
import java.util.*;
public class DigitakWatch implements Runnable{
JFrame f;
Thread t=null;
int hours=0,minutes=o,seconds=0;
String timeString=" ";
JButton b;
DigitalWatch()
{
f=new JFrame();
t=new Thread (this);
t.start();
fj=new JButton();
b.setBounda(100,100,100,50);
f.add(b);
f.setSize(300,400);
f.setLayout(null);
f.setVisible(true);
}
public void run ()
{
try{
{
while(true)
{
calender cal=calendar.getInstance();
hours=cal.get(calendar.HOUP_OF_DAY);
if(hour>12)hours-=12;
minutes=cal.get(calendar.MINUTES);
seconds=cal.get(calendr.SECONDS);
SimpleDateFormat formatter=new SimpleDateFormate("hh:mm:ss");
Date date=cal.getTime();
timeString=formatter.format(date);
printTime();
t.sleep(1000);
}
}
catch(Exception e){
}
public void printTime()
b.set Text(timeString);
}
public static void main(String args[])
new DigitalWatch();
}
}

You might also like