Bugster
Bugster

Reputation: 1594

Java swing timers and pause program?

I'm trying to simulate waiting in a java swing application, so it's basically like this: the user presses a button (Already added an actionlistener) then the program basically makes a 5 seconds pause while working in the background, then when the 5 seconds have elapsed a window shows up. ( I know how to make the window). Basically I'm asking how do you work with swing timers? Is there a command like pause() that can be invoked?

Upvotes: 4

Views: 1647

Answers (2)

trashgod
trashgod

Reputation: 205875

You might get some ideas from TimerFrame. See also Using Timers in Swing Applications.

Upvotes: 4

light_303
light_303

Reputation: 2111

you might want to check this example from 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 define an initial delay before it fires - in your case 5 seconds - and simply start it.

Upvotes: 2

Related Questions