| Author |
Can I change Swing Timer delay inside the action listener?
|
Stavros Kanarakis
Greenhorn
Joined: Sep 28, 2010
Posts: 12
|
|
Hi all,
I have an application in which a Swing timer is started with repeats(false). This is not shown in the code.
Inside that timer actionlistener, and depending on the logic, I want to stop this timer, set another delay value and restart it.
Everything works fine except for the new delay. The timer gets restarted for one time again, but it keeps getting the delay value that was given at the first time of its run. It gets always "someValue" and not "newValue".
Do you know why?
Thanks
Steve
|
Exploring Java world...
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1808
|
|
|
I would guess that you don't invoke the start() method again because start() tells the Timer to use the initialDelay, which you haven't reset.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Stavros Kanarakis wrote:
Uh-oh, that doesn't look good at all. The actionPerformed method is invoked on the EDT, and it rather looks like you might freeze the GUI with all that 'unrelated code' and the implied file I/O
|
luck, db
There are no new questions, but there may be new answers.
|
 |
 |
|
|
subject: Can I change Swing Timer delay inside the action listener?
|
|
|