For certain durations, key frame event handlers are not executed.
In the program below the key frame event handler is not executed for Duration.millis(1000 / 30.1)
If the duration is changed to Duration.millis(1000 / 30.0), then the keyframe event handler is executed.
This bug report is from a stack overflow question:
http://stackoverflow.com/questions/17004022/timeline-doesnt-work-with-some-durations
import javafx.animation.*;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.util.Duration;
import javafx.stage.Stage;
public class Ticker extends Application {
private Timeline videoTick;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) {
Duration duration = Duration.millis(1000 / 30.1);
videoTick = new Timeline(new KeyFrame(duration, new EventHandler<ActionEvent>() {
public void handle(ActionEvent actionEvent) {
System.out.println("Tick");
}
}));
videoTick.setCycleCount(Animation.INDEFINITE);
videoTick.playFromStart();
}
}
In the program below the key frame event handler is not executed for Duration.millis(1000 / 30.1)
If the duration is changed to Duration.millis(1000 / 30.0), then the keyframe event handler is executed.
This bug report is from a stack overflow question:
http://stackoverflow.com/questions/17004022/timeline-doesnt-work-with-some-durations
import javafx.animation.*;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.util.Duration;
import javafx.stage.Stage;
public class Ticker extends Application {
private Timeline videoTick;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) {
Duration duration = Duration.millis(1000 / 30.1);
videoTick = new Timeline(new KeyFrame(duration, new EventHandler<ActionEvent>() {
public void handle(ActionEvent actionEvent) {
System.out.println("Tick");
}
}));
videoTick.setCycleCount(Animation.INDEFINITE);
videoTick.playFromStart();
}
}