そのタスクを達成するには、100 ミリ秒後に四角形を削除するだけです。Flash とは異なり、JavaFX はキーフレームを中心に構築されていません。キーフレームはオプションの機能であり、オブジェクトのスケーリングなど、実際のアニメーションが必要な場合にのみ使用されます。詳細については、次のチュートリアルを参照してください: http://docs.oracle.com/javafx/2/animations/jfxpub-animations.htm
そしてコードのデモンストレーション:
public void start(Stage primaryStage) {
final Rectangle rect1 = new Rectangle(10, 70, 50, 50);
final Rectangle rect2 = new Rectangle(10, 150, 50, 50);
Button btn = new Button("Play");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
// this "timeline" just call a handler after 500 ms which hides rectangle
TimelineBuilder.create().keyFrames(new KeyFrame(Duration.millis(500), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
rect1.setVisible(false);
}
})).build().play();
// this timeline hides rectangle 2 with animation
// changing scaleXProperty() from 1 (default) to 0
TimelineBuilder.create().keyFrames(
new KeyFrame(
Duration.millis(500),
new KeyValue(rect2.scaleXProperty(), 0))
).build().play();
}
});
Pane root = new Pane();
root.getChildren().addAll(rect1, rect2, btn);
Scene scene = new Scene(root, 300, 300);
primaryStage.setScene(scene);
primaryStage.show();
}