View Single Post
  #2 (permalink)  
Old 08-01-2007, 11:24 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
Code:
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); } }
Reply With Quote