import javax.swing.*;
import java.awt.*;
import javax.swing.Timer;
import java.awt.event.ActionEvent;
public class TimerTest
{
public static void main(String[] args) {
JFrame frame = new JFrame ("Timer Test");
frame.setSize (400,400);
JPanel panel = new JPanel();
// make new action
Action action = new AbstractAction() {
public void actionPerformed (ActionEvent e){
System.out.println ("hello");
}
};
Timer timer;
timer = new Timer(5000, action);
timer.setRepeats(false);
System.out.println ("The timer has started");
timer.start();
timer.stop();
}
}