Example usage for javafx.geometry Insets Insets

List of usage examples for javafx.geometry Insets Insets

Introduction

In this page you can find the example usage for javafx.geometry Insets Insets.

Prototype

public Insets(@NamedArg("topRightBottomLeft") double topRightBottomLeft) 

Source Link

Document

Constructs a new Insets instance with same value for all four offsets.

Usage

From source file:Main.java

public static void startValueSetAnimation(final Pane parent) {
    final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle();
    Insets margin = BorderPane.getMargin(parent);
    if (margin == null) {
        margin = new Insets(0);
    }//from   w  ww  . j a v  a  2 s .c  om
    rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight()));
    rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom()));
    rectangle.setFill(Color.rgb(0, 150, 201));
    parent.getChildren().add(rectangle);

    BoxBlur bb = new BoxBlur();
    bb.setWidth(5);
    bb.setHeight(5);
    bb.setIterations(3);
    rectangle.setEffect(bb);

    FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle);
    ft.setFromValue(0.2);
    ft.setToValue(0.8);
    ft.setCycleCount(2);
    ft.setAutoReverse(true);
    ft.play();
    ft.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            parent.getChildren().remove(rectangle);
        }
    });
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    // 5 pixels space between child nodes
    HBox hbox = new HBox(5);
    // 1 pixel padding between child nodes only
    hbox.setPadding(new Insets(1));
    Rectangle r1 = new Rectangle(10, 10);
    Rectangle r2 = new Rectangle(20, 100);
    Rectangle r3 = new Rectangle(50, 20);
    Rectangle r4 = new Rectangle(20, 50);

    HBox.setMargin(r1, new Insets(2, 2, 2, 2));

    hbox.getChildren().addAll(r1, r2, r3, r4);
    root.getChildren().add(hbox);//  w  ww  .  j a  v  a  2  s.c o m

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    // 5 pixels space between child nodes
    VBox vbox = new VBox(5);
    // 1 pixel padding between child nodes only
    vbox.setPadding(new Insets(1));
    Rectangle r1 = new Rectangle(10, 10);
    Rectangle r2 = new Rectangle(20, 100);
    Rectangle r3 = new Rectangle(50, 20);
    Rectangle r4 = new Rectangle(20, 50);

    HBox.setMargin(r1, new Insets(2, 2, 2, 2));

    vbox.getChildren().addAll(r1, r2, r3, r4);
    root.getChildren().add(vbox);/* www.j  av  a2 s . co  m*/

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

From source file:Main.java

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

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);//  www  .j a v a  2s  .  com
    gridpane.setVgap(10);

    Label label = new Label("Label");
    GridPane.setHalignment(label, HPos.CENTER);
    gridpane.add(label, 0, 0);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Borders");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/*from   ww  w. ja  v a 2 s  . c o  m*/
    gridpane.setVgap(10);

    final String cssDefault = "-fx-border-color: blue;\n" + "-fx-border-insets: 5;\n" + "-fx-border-width: 3;\n"
            + "-fx-border-style: dashed;\n";
    final HBox pictureRegion = new HBox();

    pictureRegion.setStyle(cssDefault);
    gridpane.add(pictureRegion, 1, 1, 10, 10);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Borders");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/* ww  w.j av a  2s .  co  m*/
    gridpane.setVgap(10);

    final TextArea cssEditorFld = new TextArea();
    cssEditorFld.setPrefRowCount(10);
    cssEditorFld.setPrefColumnCount(100);
    cssEditorFld.setWrapText(true);
    cssEditorFld.setPrefWidth(150);
    GridPane.setHalignment(cssEditorFld, HPos.CENTER);
    gridpane.add(cssEditorFld, 0, 1);

    String cssDefault = "line1;\nline2;\n";

    cssEditorFld.setText(cssDefault);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);//from w w w . j a  v  a  2s .  co  m
    gridpane.setVgap(10);

    Label label = new Label("Label");
    GridPane.setHalignment(label, HPos.CENTER);
    gridpane.add(label, 0, 0);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/* w ww . ja v a 2  s  .c om*/
    gridpane.setVgap(10);

    final ImageView imv = new ImageView();
    final Image image2 = new Image(Main.class.getResourceAsStream("button.png"));
    imv.setImage(image2);

    final HBox pictureRegion = new HBox();

    pictureRegion.getChildren().add(imv);
    gridpane.add(pictureRegion, 1, 1);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);//from  w w w.  j  ava  2  s  . c  o  m
    gridpane.setVgap(10);

    final ImageView imv = new ImageView();
    imv.setFitWidth(100);
    final Image image2 = new Image(Main.class.getResourceAsStream("button.png"));
    imv.setImage(image2);

    final HBox pictureRegion = new HBox();

    pictureRegion.getChildren().add(imv);
    gridpane.add(pictureRegion, 1, 1);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/*ww  w  .  j av  a  2 s .  c o  m*/
    gridpane.setVgap(10);

    final ImageView imv = new ImageView();
    imv.setPreserveRatio(true);
    final Image image2 = new Image(Main.class.getResourceAsStream("button.png"));
    imv.setImage(image2);

    final HBox pictureRegion = new HBox();

    pictureRegion.getChildren().add(imv);
    gridpane.add(pictureRegion, 1, 1);

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