Java timers and pause program?

I'm trying to simulate a wait in a java swing application, so basically it is like this: the user presses a button (an actionlistener has already been added), then the program basically pauses for 5 seconds while working in the background, and then, when 5 seconds have passed, appears window. (I know how to make a window). Mostly I ask, how do you work with a swing? Is there a command like pause () that can be called?

+4
source share
2 answers

You can get some ideas from TimerFrame . See Also Using timers in Swing applications .

+4
source

you can check this example in the docs:

http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TumbleItemProject/src/components/TumbleItem.java

basically you can determine the initial delay before it fires - in your case 5 seconds - and just run it.

+2
source

Source: https://habr.com/ru/post/1388914/


All Articles