How to refresh Label text with time automatically...

Hi All,

I've a Swing application, I m communicating to another application thru socket,from that application i've to get some values and then i need to show those values on "Labels" in Swing application. These values will keep on changing with time and i've to refresh Label text accordinly.

I m new to Swing programming i m not getting any clue ,how to achieve this...Without clicking anything on the application how values will get refreshed n displayed on the Labels?

Please help me...

Thanks in advance

Thanks & regards,

Sneha

[580 byte] By [snehaa] at [2007-11-27 8:51:34]
# 1

Try looking at a TimerTask similar to the following: -

int delay = 5000;// delay for 5 sec.

int period = 1000; // repeat every sec.

Timer timer = new Timer();

timer.scheduleAtFixedRate(new TimerTask() {

public void run() {

// Task here ...

}

}, delay, period);

c0demonk3ya at 2007-7-12 21:05:01 > top of Java-index,Desktop,Core GUI APIs...
# 2
Once the value of the Label is changed with setText() method call repaint() method.
PremKumarUa at 2007-7-12 21:05:01 > top of Java-index,Desktop,Core GUI APIs...
# 3
> Once the value of the Label is changed with setText() method call repaint() method. Not necessary.
camickra at 2007-7-12 21:05:01 > top of Java-index,Desktop,Core GUI APIs...