0
我在javafx中使用動畫,所以當我點擊按鈕時它會隨着動畫一起移動,但我也想調整它的大小(它應該變得越來越小)。如何在動畫中調整按鈕的大小javafx
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
/*Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));*/
AnchorPane root=new AnchorPane();
Timeline timeline = new Timeline();
Button button = new Button();
timeline.getKeyFrames().addAll(
new KeyFrame(Duration.ZERO,
new KeyValue(button.translateXProperty(), 500),
new KeyValue(button.translateYProperty(), 500)),
new KeyFrame(Duration.seconds(.5), // set end position at 40s
new KeyValue(button.translateXProperty(), 200),
new KeyValue(button.translateYProperty(), 200)));
timeline.play();
root.getChildren().addAll(button);
primaryStage.show();
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 800, 800));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}