I discovered a bug, so I wrote the following test case to show the problem. If one makes a node invisible and later changes its visibility to true from a Timeline nothing happens.
Workaround: You can change the visibility using a KeyEvent mounted EventHandler.
public class VisibilityTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
Circle circle = new Circle(200);
circle.setFill(Color.RED);
root.setCenter(circle);
circle.setVisible(false);
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(circle.visibleProperty(), true))
);
timeline.play();
stage.setScene(scene);
stage.setTitle("Visibility test");
stage.setWidth(600);
stage.setHeight(600);
stage.show();
}
public static void main(String... arguments) {
launch(VisibilityTest.class, arguments);
}
}
Workaround: You can change the visibility using a KeyEvent mounted EventHandler.
public class VisibilityTest extends Application {
@Override
public void init() throws Exception {
}
@Override
public void start(Stage stage) throws Exception {
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
Circle circle = new Circle(200);
circle.setFill(Color.RED);
root.setCenter(circle);
circle.setVisible(false);
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(circle.visibleProperty(), true))
);
timeline.play();
stage.setScene(scene);
stage.setTitle("Visibility test");
stage.setWidth(600);
stage.setHeight(600);
stage.show();
}
public static void main(String... arguments) {
launch(VisibilityTest.class, arguments);
}
}
- duplicates
-
JDK-8146220 KeyFrame at Duration.ZERO is never getting applied
- Closed