简体   繁体   中英

JavaFX timeline listeners

Problem description:

I have an timeline that is shared between two classes and is binded with an slider. In each class I have a listener to the timeline that does something.

In one listener I manipulate an array with some objects at some point of time + some changes to the slider may appear => changes to timeline.

In the other listener I get the current time and do some stuff with it. But now I'm trying to add functionality to this listener and check when my time from slider (maxValue) will reach end and through binding also the "end" time of the timeline. When this is happening I want to redraw the slider and change the timeline to fit the new slider changes.

As an example:

I have an slider from 0 to 10 min and a timeline that is binded. So, I want when the timeline/slider reaches 10 min then to redraw the slider+ adjust the timeline to have something like: 0 to 20 min and the current time to be at 10 min.

LE: I tried to do something and I get this error (maybe helps)

java.lang.NullPointerException
at com.sun.scenario.animation.shared.SimpleClipInterpolator.interpolate(SimpleClipInterpolator.java:132)
at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:188)
at javafx.animation.Timeline.impl_playTo(Timeline.java:182)
at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:131)
at javafx.animation.Animation.impl_timePulse(Animation.java:953)
at com.sun.scenario.animation.shared.AnimationPulseReceiver$1.run(AnimationPulseReceiver.java:133)
at com.sun.scenario.animation.shared.AnimationPulseReceiver$1.run(AnimationPulseReceiver.java:131)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.scenario.animation.shared.AnimationPulseReceiver.timePulse(AnimationPulseReceiver.java:131)
at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:365)
at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:288)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:459)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:332)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:744)

Thanks in advance!

Ok now works! What was the problem: the problem was that I tried to manipulate the keyFrames from a changelistener of the timeline's currentProperty() in place.

The solution to my problem was actually to create another changelistener for the slider.maxProperty() where I added the keyFrames that I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM