質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top