This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes How to display time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to display time" Watch "How to display time" New topic

How to display time

adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
I am able to get the current system time on a JLabel but I want to see the time changing on it please any body help me
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41574
I'd probably start a thread that sleeps for whatever interval you want to update the label. Upon waking up it would set the text on the label with the current time before once again going to sleep.

Ping & DNS - my free Android networking tools app
Rob Spoor

Joined: Oct 27, 2005
Posts: 19672

javax.swing.Timer would be a perfect candidate. Its events are executed on the Event Dispatcher Thread so no need to work with invokeLater.

How To Ask Questions How To Answer Questions
wood burning stoves
subject: How to display time