Hi,
I made a timer, and it wont stop... I wanted it to only initiate the action once, so i setReapets(false) but it still just keeps on going. Even when i but timer.stop() it keeps on going... How do i fix this?
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(); } }