Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Event Driven Timer issue

$
0
0
This progam aims to be a countdown timer for the last 10 seconds of a rocket take off
However Nothing is printed to the console at all.
It is meant to print something every second I have no idea what I am doing wrong.
Any help would be great
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

public class Rocket {

	static int count = 10;

	public static void main(String[] args) {

		int delay = 1000; // milliseconds

		ActionListener taskPerformer = new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				count--;
				if (count == 0) {
					System.out.println("Blast off");
					System.exit(0);
				} else {
					System.out.println("**" + count);
				}
			}
		};

		new Timer(delay, taskPerformer).start();
	}

}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>