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("top") double top, @NamedArg("right") double right, @NamedArg("bottom") double bottom,
        @NamedArg("left") double left) 

Source Link

Document

Constructs a new Insets instance with four different offsets.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Simple Search");
    TextField txt = new TextField();
    txt.setPromptText("Search");
    txt.textProperty().addListener(new ChangeListener() {
        public void changed(ObservableValue observable, Object oldVal, Object newVal) {
            search((String) oldVal, (String) newVal);
        }//from   ww w  .j ava  2  s.  c  o m
    });

    list.setMaxHeight(180);
    for (int i = 0; i < 100; i++) {
        entries.add("Item " + i);
    }
    entries.add("A");
    entries.add("B");
    entries.add("C");
    entries.add("D");
    list.setItems(entries);

    VBox root = new VBox();
    root.setPadding(new Insets(10, 10, 10, 10));
    root.setSpacing(2);
    root.getChildren().addAll(txt, list);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Checkbox Sample");
    stage.setWidth(230);/* www.j  a  v a 2s . c  om*/
    stage.setHeight(120);

    for (int i = 0; i < names.length; i++) {
        final CheckBox cb = cbs[i] = new CheckBox(names[i]);
        cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
            public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) {
                System.out.println(new_val);
            }
        });
    }

    VBox vbox = new VBox();
    vbox.getChildren().addAll(cbs);
    vbox.setSpacing(5);

    HBox hbox = new HBox();
    hbox.setPadding(new Insets(0, 0, 0, 5));

    StackPane stack = new StackPane();
    stack.getChildren().add(hbox);

    HBox root = new HBox();
    root.getChildren().add(vbox);
    root.getChildren().add(stack);
    root.setSpacing(40);
    root.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(root);

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

From source file:kz.aksay.polygraph.desktop.LoginPane.java

public LoginPane() {
    GridPane grid = this;

    grid.setAlignment(Pos.CENTER);/*from ww w  . jav a  2  s.  c o m*/
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    sceneTitle = new Text(" ");
    sceneTitle.setId("welcome-text");
    grid.add(sceneTitle, 0, 0, 2, 1);

    userName = new Label(":");
    grid.add(userName, 0, 1);

    userTextField = new TextField();
    grid.add(userTextField, 1, 1);

    password = new Label(":");
    grid.add(password, 0, 2);

    passwordTextBox = new PasswordField();
    grid.add(passwordTextBox, 1, 2);

    signIn = new Button("");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(signIn);
    grid.add(hbBtn, 1, 4);

    final Text actionTarget = new Text();
    actionTarget.setId("action-target");
    actionTarget.setWrappingWidth(300);
    grid.add(actionTarget, 0, 6, 2, 1);

    signIn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            if (isSignInSuccess()) {
                onSignInSuccess.handle(e);
            } else {
                actionTarget.setText(
                        "?   .   !");
            }
        }
    });
}

From source file:tachyon.view.Viewer.java

public Viewer(Resource scr, Project pro) {
    super(scr, pro);
    getCenter().setCenter(new ScrollPane(view = new ImageView(image = readFromFile(scr.getFile()))));
    controls = new ToolBar();
    controls.setPadding(new Insets(5, 10, 5, 10));
    getCenter().setTop(controls);// w  w w.  j  ava2  s .  c  o  m
    controls.getItems().addAll(zIn = new Button("Zoom In"), zOut = new Button("Zoom Out"), new Separator(),
            rotate = new Button("Rotate"), new Separator(), revert = new Button("Revert"));
    zIn.setOnAction((e) -> {
        if (zoom.get() < 2.0) {
            zoom.set(zoom.get() + 0.1);
        }
    });
    zOut.setOnAction((e) -> {
        if (zoom.get() > 0.2) {
            zoom.set(zoom.get() - 0.1);
        }
    });
    zoom.addListener((ob, older, newer) -> {
        view.setFitHeight(newer.doubleValue() * image.getHeight());
        view.setFitWidth(newer.doubleValue() * image.getWidth());
    });
    rotate.setOnAction((e) -> {
        view.setRotate(view.getRotate() + 90);
    });
    revert.setOnAction((e) -> {
        zoom.set(1.0);
        view.setRotate(0);
    });
}

From source file:de.pixida.logtest.designer.automaton.ConfigFrame.java

void addOption(final String name, final Node control) {
    final Text nameText = new Text(name + ":");
    this.vbox.getChildren().add(nameText);

    final int marginLeft = 8;
    VBox.setMargin(control, new Insets(0, 0, 0, marginLeft));
    this.vbox.getChildren().add(control);
}

From source file:com.panemu.tiwulfx.control.DetailPanel.java

private void generateUI() {
    this.getChildren().removeAll(this.getChildren());
    for (String prop : propertyNames) {
        LabelSeparator labelSeparator = new LabelSeparator("");
        labelSeparator.setText(prop);//  w ww  .  j a  v a2 s . c  o m
        VBox.setMargin(labelSeparator, new Insets(10, 0, 0, 0));
        this.getChildren().add(labelSeparator);
        Label lblValue = new Label();
        lblValue.getStyleClass().add("valueLabel");
        lblValue.setWrapText(true);
        this.getChildren().add(lblValue);

        componentMap.put(prop, lblValue);
    }
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);// w w w. ja va2 s.  c o m
    stage.setHeight(550);

    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));

    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    firstNameCol.setSortType(TableColumn.SortType.DESCENDING);
    lastNameCol.setSortable(false);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(250);/*from  w  ww.j a v a 2s. co m*/
    stage.setHeight(150);

    final ToggleGroup group = new ToggleGroup();

    RadioButton rb1 = new RadioButton("A");
    rb1.setToggleGroup(group);
    rb1.setUserData("A");

    RadioButton rb2 = new RadioButton("B");
    rb2.setToggleGroup(group);
    rb2.setUserData("B");

    RadioButton rb3 = new RadioButton("C");
    rb3.setToggleGroup(group);
    rb3.setUserData("C");

    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (group.getSelectedToggle() != null) {
                System.out.println(group.getSelectedToggle().getUserData().toString());
            }
        }
    });

    HBox hbox = new HBox();
    VBox vbox = new VBox();

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    vbox.setSpacing(10);

    hbox.getChildren().add(vbox);
    hbox.setSpacing(50);
    hbox.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    TextField notification = new TextField();

    MenuItem item1 = new MenuItem("About");
    item1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            System.out.println("About");
        }// w  w w  .  j ava2s . c  o m
    });
    MenuItem item2 = new MenuItem("Preferences");
    item2.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            System.out.println("Preferences");
        }
    });

    final ContextMenu contextMenu = new ContextMenu(item1, item2);
    contextMenu.setOnShowing(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent e) {
            System.out.println("showing");
        }
    });
    contextMenu.setOnShown(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent e) {
            System.out.println("shown");
        }
    });
    notification.setContextMenu(contextMenu);
    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(notification, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Radio Button Sample");
    stage.setWidth(250);/*from  www. ja v a  2 s .com*/
    stage.setHeight(150);

    final ToggleGroup group = new ToggleGroup();

    RadioButton rb1 = new RadioButton("A");
    rb1.setToggleGroup(group);
    rb1.setUserData("A");

    RadioButton rb2 = new RadioButton("B");
    rb2.setToggleGroup(group);
    rb2.setUserData("B");

    RadioButton rb3 = new RadioButton("C");
    rb3.setToggleGroup(group);
    rb3.setUserData("C");

    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (group.getSelectedToggle() != null) {
                System.out.println(group.getSelectedToggle().getUserData().toString());
            }
        }
    });

    HBox hbox = new HBox();
    VBox vbox = new VBox();

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    vbox.setSpacing(10);

    hbox.getChildren().add(vbox);
    hbox.setSpacing(50);
    hbox.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}