timer

Tom Eugelink tbee at tbee.org
Tue Mar 6 04:05:26 PST 2012


I have been pondering this as well, but would this do the initial delay and the quick repeat afterwards? Or should I use the first KeyFrame for the initial delay and a second KeyFrame for the repeat delay (which just jumps the timeline back to the first). I could wrap this into a real timer class then.


On 6-3-2012 11:56, Michael Heinrichs wrote:
> Hi Tom,
>
> I think you can either use a standard Timer or a Timeline with a single KeyFrame and cycleCount INDEFINITE. Your logic needs to go into the onFinished handler. There is a property in Timeline to set an initial delay.
>
> - Michael
>
>
> On 06.03.2012, at 11:44, Tom Eugelink wrote:
>
>> For the second time I'm in need of a timer logic, similar to Swing's timer class.
>>
>> What I want to do is that when there is a mouse-pressed event, a timer is started with an initial delay of 500 ms or s,o and then it must repeat every 100 or 200 ms and increment a value. Real world: the user presses-and-holds the LMB over an arrow in the spinner control, and it must start incrementing; tak tak tak tak tak, maybe picking up speed or step size as the button is held.
>>
>> There is AFAIK no timer class in JavaFX. There is an AnimationTimer, but that is closely linked to the repaint frequency, this usage should not be.
>>
>> The other time I needed a timer, all I needed was a single delayed execution, so I abused the PauseTransition and the onFinished event. But now I need the repeating behavior and Animations do not have an onTrigger or something.
>>
>> What is the best way to do a Swing like timer in JavaFX?
>>
>> Tom
>




More information about the openjfx-dev mailing list