Example usage for javafx.scene.layout HBox setHgrow

List of usage examples for javafx.scene.layout HBox setHgrow

Introduction

In this page you can find the example usage for javafx.scene.layout HBox setHgrow.

Prototype

public static void setHgrow(Node child, Priority value) 

Source Link

Document

Sets the horizontal grow priority for the child when contained by an hbox.

Usage

From source file:Main.java

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

    HBox hbox = new HBox();
    Button button1 = new Button("Add");
    Button button2 = new Button("Remove");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);//from   w w  w .  j  a v  a2s.co  m

    HBox.setMargin(button1, new Insets(1, 1, 1, 1));

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

From source file:Main.java

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

    HBox hbox = new HBox();
    Button button1 = new Button("Add");
    Button button2 = new Button("Remove");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);//from  ww w  .jav a 2 s .  c  o m

    System.out.println(hbox.getAlignment());

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

From source file:Main.java

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

    HBox hbox = new HBox();
    Button button1 = new Button("Add");
    Button button2 = new Button("Remove");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);//from  w ww .  j av a  2s.  c  o m

    System.out.println(hbox.getContentBias());

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

From source file:Main.java

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

    HBox hbox = new HBox();
    Button button1 = new Button("Add               ");
    Button button2 = new Button("Remove   ");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    root.getChildren().add(hbox);/*from www .j av a 2  s .  c om*/
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

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

    HBox hbox = new HBox();
    Button button1 = new Button("Add               ");
    Button button2 = new Button("Remove   ");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);/*  w w  w . ja  va  2s  .  c  om*/

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

From source file:Main.java

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

    HBox hbox = new HBox(8);//space
    Button button1 = new Button("Add               ");
    Button button2 = new Button("Remove   ");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);/*www . j  a v a2s .  c om*/

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

From source file:Main.java

private VBox getCenter() {
    Label nameLbl = new Label("Name:");
    TextField nameFld = new TextField();
    HBox.setHgrow(nameFld, Priority.ALWAYS);
    HBox nameFields = new HBox(nameLbl, nameFld);

    Label descLbl = new Label("Description:");
    TextArea descText = new TextArea();
    descText.setPrefColumnCount(20);// w w w. ja  v a 2  s. c o m
    descText.setPrefRowCount(5);
    VBox.setVgrow(descText, Priority.ALWAYS);

    VBox center = new VBox(nameFields, descLbl, descText);
    return center;
}

From source file:org.jacp.demo.components.ContactAddDialog.java

private void createAddContactDialog() {
    final VBox box = new VBox();
    box.getStyleClass().add("jacp-option-pane");
    box.setMaxSize(300, Region.USE_PREF_SIZE);
    // the title//  w  ww .j  av a  2s .c o m
    final Label title = new Label("Add new category");
    title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE);
    VBox.setMargin(title, new Insets(2, 2, 10, 2));

    final HBox hboxInput = new HBox();
    final Label nameLabel = new Label("category name:");
    HBox.setMargin(nameLabel, new Insets(2));
    final TextField nameInput = new TextField();
    HBox.setMargin(nameInput, new Insets(0, 0, 0, 5));
    HBox.setHgrow(nameInput, Priority.ALWAYS);
    hboxInput.getChildren().addAll(nameLabel, nameInput);

    final HBox hboxButtons = new HBox();
    hboxButtons.setAlignment(Pos.CENTER_RIGHT);
    final Button ok = new Button("OK");
    HBox.setMargin(ok, new Insets(6, 5, 4, 2));
    final Button cancel = new Button("Cancel");
    HBox.setMargin(cancel, new Insets(6, 2, 4, 5));
    cancel.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent arg0) {
            JACPModalDialog.getInstance().hideModalDialog();
        }
    });

    ok.setDefaultButton(true);
    ok.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent actionEvent) {
            final String catName = nameInput.getText();
            if (catName != null && StringUtils.hasText(catName)) {
                // contacts
                final Contact contact = new Contact();
                contact.setFirstName(catName);
                parent.getContext().send(contact);
                JACPModalDialog.getInstance().hideModalDialog();
            }
        }
    });

    hboxButtons.getChildren().addAll(ok, cancel);
    box.getChildren().addAll(title, hboxInput, hboxButtons);
    JACPModalDialog.getInstance().showModalDialog(box);
}

From source file:org.pdfsam.ui.module.ProgressPane.java

public ProgressPane() {
    this.getStyleClass().add("progress-pane");
    this.statusLabel.getStyleClass().add("progress-status");
    this.failed.setVisible(false);
    this.open.setVisible(false);
    this.bar.getStyleClass().add("pdfsam-footer-bar");
    StackPane buttons = new StackPane(failed, open);
    HBox progressStatusBox = new HBox(statusLabel, buttons);
    progressStatusBox.getStyleClass().add("progress-status-pane");
    HBox.setHgrow(statusLabel, Priority.ALWAYS);
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    getChildren().addAll(progressStatusBox, bar);
    eventStudio().addAnnotatedListeners(this);
}

From source file:org.pdfsam.ui.news.NewsStage.java

@Inject
public NewsStage(Collection<Image> logos, StylesConfig styles,
        @Named("newsDisplayPolicy") PreferenceComboBox<KeyStringValueItem<String>> newsDisplayPolicy) {
    BorderPane containerPane = new BorderPane();
    browser.setId("newsBrowser");
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().add("-pdfsam-news-pane");
    containerPane.setCenter(browser);/*www.  j a  v  a 2s. co  m*/
    HBox bottom = new HBox();

    ClosePane closePane = new ClosePane();
    HBox.setHgrow(closePane, Priority.ALWAYS);
    HBox comboPanel = new HBox(new Label(DefaultI18nContext.getInstance().i18n("Show this:")),
            newsDisplayPolicy);
    comboPanel.getStyleClass().addAll(Style.CONTAINER.css());
    comboPanel.getStyleClass().add("-pdfsam-news-pane-bottom");
    bottom.getChildren().addAll(comboPanel, closePane);
    containerPane.setBottom(bottom);
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("What's new"));
    getIcons().addAll(logos);
    setMaximized(false);
}