Example usage for javafx.scene.shape Rectangle Rectangle

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

Introduction

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

Prototype

public Rectangle(double width, double height, Paint fill) 

Source Link

Document

Creates a new instance of Rectangle with the given size and fill.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);//from w  w w .  j  a v  a  2s  .  c om

    Rectangle rect = new Rectangle(200, 200, Color.RED);
    ScrollPane s1 = new ScrollPane();
    s1.setPannable(true);
    s1.setPrefSize(120, 120);
    s1.setContent(rect);

    root.getChildren().add(s1);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group group = new Group();
    Scene scene = new Scene(group);

    StackPane stack = new StackPane();
    stack.getChildren().addAll(new Rectangle(100, 100, Color.BLUE));

    group.getChildren().add(stack);//from   www  .  j  a va  2  s.  c  o  m

    stage.setTitle("Welcome to JavaFX!");
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);//from   w  w w. j av a2s  .  c om

    Rectangle rect = new Rectangle(200, 200, Color.RED);
    ScrollPane s1 = new ScrollPane();
    s1.setPrefSize(120, 120);
    s1.setContent(rect);

    s1.vvalueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            System.out.println(new_val.intValue());
        }
    });
    s1.hvalueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            System.out.println(new_val.intValue());
        }
    });
    root.getChildren().add(s1);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Rectangle rect1 = new Rectangle(100, 50, Color.LIGHTGRAY);
    rect1.setStroke(Color.BLACK);

    Rectangle rect2 = new Rectangle(100, 50, Color.YELLOW);
    rect2.setStroke(Color.BLACK);

    Translate translate = new Translate(50, 10);
    Rotate rotate = new Rotate(30, 0, 0);
    Scale scale = new Scale(0.5, 0.5);
    Shear shear = new Shear(0.5, 0.5);
    rect2.getTransforms().addAll(translate, rotate, scale, shear);

    Pane root = new Pane(rect1, rect2);
    root.setPrefSize(200, 100);//  w  w  w .  jav  a2 s  .  c  om
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("");
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group group = new Group();
    Scene scene = new Scene(group);

    StackPane stack = new StackPane();
    stack.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
    stack.getChildren().addAll(new Rectangle(100, 100, Color.BLUE));

    group.getChildren().add(stack);//  www .  j av a 2 s .  co  m

    stage.setTitle("Welcome to JavaFX!");
    stage.setScene(scene);
    stage.sizeToScene();
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Group group = new Group();
    Scene scene = new Scene(group, 300, 150);
    stage.setScene(scene);//from ww  w.  j a  v a 2  s . c o m
    stage.setTitle("Sample");

    TabPane tabPane = new TabPane();
    Tab tab = new Tab();
    tab.setText("new tab");
    tab.setContent(new Rectangle(200, 200, Color.LIGHTSTEELBLUE));
    tabPane.getTabs().add(tab);
    tabPane.getTabs().add(new Tab());

    group.getChildren().add(tabPane);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Sample");
    stage.setWidth(300);/*from   w ww.j a va2  s. c  o m*/
    stage.setHeight(190);

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

    Rectangle rect = new Rectangle(50, 50, Color.RED);
    rect.getTransforms().add(new Rotate(45, 0, 0)); //

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

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

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 400, 300, Color.WHITE);

    GridPane gridpane = new GridPane();

    ComboBox<Rectangle> cmb = new ComboBox<Rectangle>();
    cmb.getItems().addAll(new Rectangle(10, 10, Color.RED), new Rectangle(10, 10, Color.GREEN),
            new Rectangle(10, 10, Color.BLUE));

    gridpane.add(cmb, 2, 0);/*  ww  w .  j a v a 2 s  . co  m*/

    root.getChildren().add(gridpane);
    primaryStage.setScene(scene);

    primaryStage.show();
}

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  w  ww.jav 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();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Text t1 = new Text("Drop Shadow!");
    t1.setFont(Font.font(24));// w  ww  . j av  a  2  s .  com
    t1.setEffect(new DropShadow());

    Text t2 = new Text("Blur!");
    t2.setFont(Font.font(24));
    t2.setEffect(new BoxBlur());

    Text t3 = new Text("Glow!");
    t3.setFont(Font.font(24));
    t3.setEffect(new Glow());

    Text t4 = new Text("Bloom!");
    t4.setFont(Font.font("Arial", FontWeight.BOLD, 24));
    t4.setFill(Color.WHITE);
    t4.setEffect(new Bloom(0.10));

    Rectangle rect = new Rectangle(100, 30, Color.GREEN);
    StackPane spane = new StackPane(rect, t4);

    HBox root = new HBox(t1, t2, t3, spane);
    root.setSpacing(20);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Applying Effects");
    stage.show();
}