Example usage for javafx.scene.shape Rectangle translateXProperty

List of usage examples for javafx.scene.shape Rectangle translateXProperty

Introduction

In this page you can find the example usage for javafx.scene.shape Rectangle translateXProperty.

Prototype

public final DoubleProperty translateXProperty() 

Source Link

Document

Defines the x coordinate of the translation that is added to this Node 's transform.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    DoubleProperty translate = new SimpleDoubleProperty();
    stage.setTitle("Hello JavaFX");
    Rectangle node1 = RectangleBuilder.create().x(0).y(0).width(10).height(10).fill(Color.RED).build();
    node1.translateXProperty().bind(translate);

    Parent parent = GroupBuilder.create().children(node1).translateX(250).translateY(250).build();
    stage.setScene(SceneBuilder.create().width(500).height(500).root(parent).build());
    stage.show();//  w  w w  .j  a  va  2s .c o m

    TimelineBuilder.create().cycleCount(Timeline.INDEFINITE)
            .keyFrames(new KeyFrame(Duration.seconds(0), new KeyValue(translate, -50)),
                    new KeyFrame(Duration.seconds(2), new KeyValue(translate, 250)))
            .build().play();
}