You will have to use the javax.swing.Timer for doing the Timer examples in Java. This class is easier to use. Just instantiate it passing each how long (in milliseconds) we want to let us know and ActionListener, which method actionPerformed () will run periodically. Then just call the method start () when we want the timer starts counting. The code may look like this:
Code:
Timer timer = new Timer (TimeInMilliseconds, new ActionListener ()
(
public void actionPerformed (ActionEvent e)
(
// Here you have to execute the code.
)
));
...
timer.start ();
Bookmarks