Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing a time to a Swing Timer

 
James Filson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2580
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic