Thread: Java Timer
View Single Post
Old 12-09-2004, 11:53 PM   PM User | #5
FalcorTheDog
New to the CF scene

 
Join Date: Dec 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
FalcorTheDog is an unknown quantity at this point
Neat, I sort of get it. But is there any way to do it without these try/catch statements? For example, why doesn't this simple code work (by "work" I mean displaying "test" every second):

Code:
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() );
   }

}
Thanks for everyone's help!
FalcorTheDog is offline   Reply With Quote