I have a timer set up to run constinuously every few seconds. It's working fine. However, I want to add a new button that makes the timer go exactly 10 times. So I wrote:
The timer itself if supposed to output text to the screen. But I end up getting 0,1,...,9, and then one set of the print out of the timer. It looks like the timer doesn't actually start until all the code in that method is executed, at which point the timer will start only once. I'm interested in the outputed data on the 10th iteration. How should I go about getting it? Thanks Alot! Kate
Are you using java.util.Timer? You can tell Timer to call a task object at some interval. In the task object you can count how many times it has been run. After 10 times it can call cancel on itself. Does that fit your needs?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Feb 11, 2004
Thanks to all the help, I finally got my timer to work exactly 10 times! Although I'm still stuck with a major problem. I am calling three function, like this:
Each method has a print statement in its body. When I run this code, I get the following output: inside clear method inside verify method inside timer.start action <- this one is repeated 10 times, obviously.
Why are my methods not executed in the order I write them in?! Why is it that no matter the order in my code, and how many lines, and pauses I add in my code, timer.start always get executed last?
Please help me out on this one, I can't even begin to understand how I can possibly change this annoying behavior!!! Sigh.
Thanks Alot, Kate
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com