Example usage for javafx.scene.shape Rectangle relocate

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

Introduction

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

Prototype

public void relocate(double x, double y) 

Source Link

Document

Sets the node's layoutX and layoutY translation properties in order to relocate this node to the x,y location in the parent.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);//from ww  w  .j  a  v a 2s. co  m
    stage.setTitle("");

    VBox vb = new VBox();

    Pane canvas = new Pane();
    canvas.setStyle("-fx-background-color: black;");
    canvas.setPrefSize(200, 200);
    Circle circle = new Circle(50, Color.BLUE);
    circle.relocate(20, 20);
    Rectangle rectangle = new Rectangle(100, 100, Color.RED);
    rectangle.relocate(70, 70);
    canvas.getChildren().addAll(circle, rectangle);

    vb.getChildren().add(canvas);

    scene.setRoot(vb);
    stage.show();
}