import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; public class TrafficGenerator implements ActionListener { private int start_delay; public TimerTest(int i) { start_delay=i; } private Timer testTimer; public void start() { testTimer = new Timer(START_DELAY, this); testTimer.start(); JOptionPane.showMessageDialog(null, " Quit? " ); System.exit(0); } public void stop() { testTimer.stop(); } public void setDelay(int i) { testTimer.setDelay(i); } public int getDelay() { return testTimer.getDelay(); } public void actionPerformed(ActionEvent e) { this.setDelay(ii++); System.out.println(ii); } public static void main(String[] args) { TrafficGenerator tt = new TrafficGenerator(); tt.start(); } }