Using RectangleBuilder to create Rectangle : RectangleBuilder « JavaFX « Java






Using RectangleBuilder to create Rectangle

  


import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.RectangleBuilder;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    final Rectangle rect = RectangleBuilder
                           .create()
                           .x(100)
                           .y(100)
                           .width(50)
                           .height(50)
                           .build();

    g.getChildren().add(rect);

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

   
    
  








Related examples in the same category

1.Using RectangleBuilder to create Rectangle