0

How to use timer in java swing?

i want to develop puzzle game using java swing. for that i want to add timer for that. i use lot of techniquesm. but it won't work in netbeans. so anyone know,please give me a correct solution

17th Apr 2017, 4:40 AM
Prasanth V
Prasanth V - avatar
1 Answer
0
You need a CountDownTimer. Make a new object of the CountDownTimer. It takes 2 arguments, millisInFuture and countDownInterval, and has two methods that you can override, onTick() and onFinish(). You can use millisUntilFinished argument of the onTick() method to display the remaining time. The timer can be started be calling the start method and it can be stopped using the cancel method.
17th Apr 2017, 5:35 AM
Prabhjot Singh
Prabhjot Singh - avatar