I have the following code to display current time in swing application.
private void startClock(StateBar stateBar)
{
ActionListener listener = new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
stateBar.setTime(Clock.currentDateStr());
}
};
timer = new Timer(1000,listener);
timer.start();
}
But it seems to execute listener code not at timer start but after one second from start. I mean when I open the panel with my clock the date appears with 1 second delay. Is it possible to fire execution on my code immediately at start of the timer?