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!