How to make a timer that waits for one second and then continues with the program?

How do I create a timer compatible in an oriented program JFrane

/ JPanel

where it just waits for 1 second and then continues with the rest of the code?

I don't want to use Thread.sleep();

as it is causing problems for me.

+3


source to share


2 answers


You can use javax.swing.Timer for such tasks . It integrates with Event Dispatching Thread (EDT).



+4


source


TimeUnit.SECONDS.sleep(1)

      



More info here: How to delay Java?

-1


source







All Articles