Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a Timer that waits one second & then continues on with program?

How could I create a timer that is compatible in a JFrane/JPanel oriented program where it just waits 1 second, and then continues on with the rest of the code?

I do not want to use Thread.sleep(); since it is causing problems for me.

like image 205
Alec Stanton Avatar asked Nov 28 '25 11:11

Alec Stanton


1 Answers

For this kind of tasks you can use javax.swing.Timer. It integrates with the Event Dispatching Thread (EDT).

like image 136
Puce Avatar answered Dec 01 '25 01:12

Puce