0

Is there anyway to pause a Java Swing Timer, i'm planning to implement a feature in this java 2D environment and want the ability to pause the movement graphics.

  • Duplicate? [Pausing/stopping and starting/resuming Java TimerTask continuously?](http://stackoverflow.com/questions/2098642/pausing-stopping-and-starting-resuming-java-timertask-continuously/2098678#2098678) – DavidPostill Jun 27 '14 at 15:34

3 Answers3

0

Timers cannot be paused. You'll have to add the functionality yourself. Here's an example that pauses the timer on mouse over:

http://www.java2s.com/Code/Java/Swing-JFC/Anappletthatcountsdownfromaspecifiedtime.htm

Troncoso
  • 2,343
  • 3
  • 33
  • 52
0

You can use the stop() method and then restart()

camickr
  • 321,443
  • 19
  • 166
  • 288
0

There is no way to pause a Swing Timers once started. But you can make use of Timer class setDelay(int delay) to delay between successive action events

SparkOn
  • 8,806
  • 4
  • 29
  • 34