Click to See Complete Forum and Search --> : Showing a label displaying time in Java.


sjeevan
November 5th, 1999, 12:58 AM
Hi,

I need to show a label, in my Java application, which will display the current time.
It would also automatically update it self as the time changes.

In C (Windows SDK) / VB, this could be acheived by having/ creating a timer event/ control and
when ever the timer event is received by the application, the text displayed in the label, updated.

But how could it be done in Java. ?

The details of displaying time, using java.util.GregorianCalendar

are simple,
but how/ when to keep updating the label, constantly, during the life of the application.

Would an example be available, somewhere, too ?

regards
Jeevan

Erbeere
November 5th, 1999, 08:20 AM
Hi

I am not quite sure but I think that it must work if you are using threads. You create a thread which holds your label. In that label you are displaying the time and the runmethod of the label is repainting it the whole time.
I have done it in an applet (see on my homepage with the time) and it is working.

Bye Thomas

go to my homepage at http://private.freepage.de/thomas79

poochi
November 5th, 1999, 09:18 AM
There is a "Timer" class in Swing. Check it out ..

sjeevan
November 5th, 1999, 10:53 PM
Hi Thomas,

Thanks for the info. Yes what u think is exactly what I am looking for.

Unfortunately I do not know German.
So could not locate the link on your homepage where you have placed your Applet you mention.

regards
Jeevan S