import javax.swing.Timer;
import java.awt.event.*;
public class TimerTestRx
{
public static void main( String args[] )
{
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener()
{
int count = 0;
public void actionPerformed(ActionEvent evt)
{
System.out.println( "count = " + count++ );
if(count > 10) {
((Timer)evt.getSource()).stop();
System.exit(0);
}
}
};
Timer test = new Timer(delay, taskPerformer);
test.start();
System.out.println( test.isRunning() );
System.out.println( test.getDelay() );
// Can't do much after we get to this statement.
// test.stop();
System.out.println( test.isRunning() );
String s = "<html>We need something to keep the jvm from<br>" +
"exiting while we look for some timer activity";
javax.swing.JOptionPane.showMessageDialog(null, s);
}
}