Please help me in my code..
I have a program in swing in which i had to display the “shift” of working through a label, the 24 hrs of the day will have to divide in 3 shifts..
The main problem is that the shift has to changed automatically after specified time..
that is,
Label has to display
Shift=1 for time 00:00:01 to 08:00:00
and
Shift=2 for time 08:00:01 to 06:00:00
and
Shift=3 for time 06:00:01 to 00:00:00
and this shift change must occur automatically………
Hope i am clear with my question.
You might want to use a Timer – either java.util.Timer or javax.swing.Timer. The first one allows you to set the target time explicitely, while the last one easier collaborates with Swing (e.g. the actions are automatically executed on the event dispatch thread, as needed for GUI changes).
The timer allows you to execute arbitrary code when the time to wait is up, such as changing the labels text.