aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Passing a time to a Swing Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Passing a time to a Swing Timer" Watch "Passing a time to a Swing Timer" New topic
Author

Passing a time to a Swing Timer

James Filson
Greenhorn

Joined: Nov 24, 2009
Posts: 11
Hi,

I seem to be having a very strange issue with using a simple Swing Timer - this works and runs the timer every 1000 milliseconds:


However if I set int time = 1000; (so that I can change this at will), and then pass it in this way:

...the method runs what seems as quickly as it can, taking no notice of the time.

Does anyone have any idea why it can't accept an int as a variable? I've checked and double-checked and I've really got no idea! Thank you in advance!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
Works fine for me.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

James Filson
Greenhorn

Joined: Nov 24, 2009
Posts: 11
Rob Camick wrote:Works fine for me.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.


Thank you. The issue turned out to be the fact I was setting the time and calling the timer in the same thread... it seemed one was running before the other. Thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a time to a Swing Timer