I'm looking for a way around the problem with showAndWait call. I've thought onFinishedProperty is fired when the animation process is over, still im unable to call showAndWait because of error saying that im trying to call it during animation process. Is there anyway to call my dialog right after finish of animation?
TextInputDialog dialog = new TextInputDialog("Litera");
dialog.setTitle("");
dialog.setHeaderText("");
dialog.setContentText("Wybierz literę:");
for(int i = 0 ; i<pieChartData.size();i++)
System.out.println(pieChartData.get(i));
RotateTransition rotateTransition = new RotateTransition();
rotateTransition.setDuration(Duration.millis(5000));
rotateTransition.setNode(fortuna);
rotateTransition.setCycleCount(1);
rotate.setOnAction(
(e)->{
fortuna.setRotate(0);
rotate.setDisable(true);
rotateTransition.setAutoReverse(false);
rotateTransition.setByAngle((int)(Math.random()*10800+360));
rotateTransition.play();
rotateTransition.onFinishedProperty().set(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println(fortuna.getRotate());
Optional<String> result = dialog.showAndWait();
rotate.setDisable(false);
}
}
);
});
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: showAndWait is not allowed during animation or layout processing
at javafx.controls/javafx.scene.control.Dialog.showAndWait(Unknown Source)
at Main$1.handle(Main.java:78)
at Main$1.handle(Main.java:1)
at javafx.graphics/javafx.animation.Animation.finished(Unknown Source)
at javafx.graphics/javafx.animation.AnimationAccessorImpl.finished(Unknown Source)
at javafx.graphics/com.sun.scenario.animation.shared.SingleLoopClipEnvelope.timePulse(Unknown Source)
at javafx.graphics/javafx.animation.Animation.doTimePulse(Unknown Source)
at javafx.graphics/javafx.animation.Animation$1.lambda$timePulse$0(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/javafx.animation.Animation$1.timePulse(Unknown Source)
at javafx.graphics/com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(Unknown Source)
at javafx.graphics/com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)