I would recommend creating a class that extends JPanel and implements ActionListener, and using the Timer class. A Timer will periodically fire events (for example, once per second) which you can respond to (update the UI or close the form) in the actionPerformed method.
Using a countdown timer [closed]
Frage
I'm new to Java and I'm taking grade 11 computer science. For our final project, we have to make a game and I'm doing JEOPARDY. When you click on the question you want, a new form comes up showing that questions and the 4 choices for the answer (I'm doing multiple choice for simplicity) On that form, I want there to be a countdown from 20 to 0. Once the timer runs out, I want the form to close. The user needs to be able to see the timer.
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow