2016-05-31 14 views

答えて

0

一つの方法は、両方の方向のスケーリングとは対照的にTimeline内幅修正をアニメーション化するであろう。

  • Pos.CENTER:あなたがRectangleの親

    アライメント値の位置合わせを変更することによって方向をシミュレートすることができる変化は両方向

  • Pos.CENTER_LEFTに発生しているかのように表示される:変化かのように表示されます右
  • Pos.CENTER_RIGHTから発生している:変更は、左
から発生しているかのように表示されますあなたが最良のあなたの現在のステータスバーに合ったものを選ぶことができアライメントで実験することで


ビジュアル表現:アライメントの

注文:Right | Center | Left

right center left


SSCCE:

public class RectangleWidthAnimation extends Application{ 
    @Override 
    public void start(Stage primaryStage) throws Exception { 
     Rectangle statusBar = new Rectangle(300, 100); 
     Button animationButton = new Button("Animate width decrease by 25"); 
     animationButton.setOnAction(event -> { 
      System.out.println("Animation start: width = " + statusBar.getWidth()); 
      KeyValue widthValue = new KeyValue(statusBar.widthProperty(), statusBar.getWidth() - 25); 
      KeyFrame frame = new KeyFrame(Duration.seconds(2), widthValue); 
      Timeline timeline = new Timeline(frame); 
      timeline.play(); 
      timeline.setOnFinished(finishedEvent -> System.out.println("Animation end: width = " + statusBar.getWidth())); 
     }); 

     VBox container = new VBox(10, statusBar, animationButton); 

     //Experiment with these alignments 
     container.setAlignment(Pos.CENTER); 
     //container.setAlignment(Pos.CENTER_LEFT); 
     //container.setAlignment(Pos.CENTER_RIGHT); 

     primaryStage.setScene(new Scene(container, 350, 150)); 
     primaryStage.show(); 
    } 
} 


上記の代わりに、あなたはおよそ here

を読み取ることができる、トランジションを使用することができ
関連する問題