Hi, I just started playing with timers today, so I'm not too sure what I'm doing. All I want is to get something simple to work... Here I'm trying to display "test" once every second. Why isn't it working? The timer appears to be running, but the actionevent isn't working.
import javax.swing.Timer;
import java.awt.event.*;
public class TimerTest
{
public static void main( String args[] )
{
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
System.out.println( "test" );
}
};
Timer test = new Timer(delay, taskPerformer);
test.start();
System.out.println( test.isRunning() );
System.out.println( test.getDelay() );
test.stop();
System.out.println( test.isRunning() );
}
}
Thanks