File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I change Swing Timer delay inside the action listener?

 
Stavros Kanarakis
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5116
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic