Example usage for javafx.animation TranslateTransition TranslateTransition

List of usage examples for javafx.animation TranslateTransition TranslateTransition

Introduction

In this page you can find the example usage for javafx.animation TranslateTransition TranslateTransition.

Prototype

public TranslateTransition(Duration duration, Node node) 

Source Link

Document

The constructor of TranslateTransition

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Sample");
    stage.setWidth(300);/*w w  w  .  ja  v a2 s  . co  m*/
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    Rectangle rect = new Rectangle(100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(Color.VIOLET);

    TranslateTransition tt = new TranslateTransition(Duration.millis(2000), rect);
    tt.setByX(200f);
    tt.setAutoReverse(true);

    tt.play();

    vbox.getChildren().add(rect);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:com.loyalty.controllers.DashboardController.java

private void animate() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenDimension = tk.getScreenSize();
    TranslateTransition transition = new TranslateTransition(new Duration(30000), lbl_promotion);
    transition.setInterpolator(Interpolator.LINEAR);
    transition.setCycleCount(Timeline.INDEFINITE);
    transition.setFromX(screenDimension.getWidth());
    transition.setToX(-screenDimension.getWidth());
    transition.play();/* www. java  2  s . c o  m*/
}