Im trying to display a count down timer and i dont know how to display the time left after every second. For example,if a user types in 5, i want to display the time going 5 ,4 ,3 ,2,1
I think im close,but i need some help.The code below almost works.
I think im close,but i need some help.The code below almost works.
Code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.JFrame;
public class Temp extends JFrame implements ActionListener{
/** * @param countdown number of milliseconds */
public Temp(int countdown) {
super();
setVisible(true);
Timer timer = new Timer(countdown, this);
timer.start();
}
public void actionPerformed(ActionEvent e)
{
System.out.println("done");
}
public static void main(String args[]) {
Temp t = new Temp(5000);
}
}