Example usage for javafx.scene.layout GridPane setHgrow

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

Introduction

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

Prototype

public static void setHgrow(Node child, Priority value) 

Source Link

Document

Sets the horizontal grow priority for the child when contained by a gridpane.

Usage

From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java

public static void showFatalException(final String title, final String message, final Throwable exception) {
    final Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Error");
    alert.setHeaderText(title);//from   ww  w.  j av  a2  s .  com
    alert.setContentText(message);

    final Label label = new Label("Details:");

    final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    final GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 180, 250);

    String[] keys = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#" };

    GridPane numPad = new GridPane();
    for (int i = 0; i < 12; i++) {
        Button button = new Button(keys[i]);
        button.getStyleClass().add("num-button");
        numPad.add(button, i % 3, (int) Math.ceil(i / 3));
    }/*from   w w w  .  jav a2s  . c om*/

    Button call = new Button("Call");
    call.setId("call-button");
    call.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    numPad.add(call, 0, 4);

    GridPane.setColumnSpan(call, 3);
    GridPane.setHgrow(call, Priority.ALWAYS);

    root.setCenter(numPad);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:org.mskcc.shenkers.control.alignment.AlignmentOverlay.java

private void populateGridPane() {
    ObservableList<Node> children = this.getChildren();
    children.clear();/*from  w ww . ja va  2 s .c om*/
    int l = nodes.size();
    boolean flip = flipProperty.get();

    for (int i = 0; i < l; i++) {
        Node n = nodes.get(i);
        GridPane.setHalignment(n, HPos.CENTER);
        GridPane.setValignment(n, VPos.CENTER);
        GridPane.setHgrow(n, Priority.ALWAYS);
        GridPane.setVgrow(n, Priority.ALWAYS);
        GridPane.setRowIndex(n, 0);
        GridPane.setColumnIndex(n, flip ? l - i - 1 : i);
        children.add(n);
    }
}

From source file:gov.va.isaac.gui.listview.operations.ParentReplace.java

@Override
public void init(ObservableList<SimpleDisplayConcept> conceptList) {
    super.init(conceptList);
    root_.add(new Label("Replace: "), 0, 0);

    replaceOptions_ = new ComboBox<>();
    replaceOptions_.setMaxWidth(Double.MAX_VALUE);
    replaceOptions_.setPromptText("-Populate the Concepts List-");
    root_.add(ErrorMarkerUtils.setupErrorMarker(replaceOptions_, replaceOptionsInvalidString_), 1, 0);
    ComboBoxSetupTool.setupComboBox(replaceOptions_);

    root_.add(new Label("With Parent: "), 0, 1);
    withConcept_ = new ConceptNode(null, true);
    root_.add(withConcept_.getNode(), 1, 1);

    GridPane.setHgrow(withConcept_.getNode(), Priority.ALWAYS);
    FxUtils.preventColCollapse(root_, 0);
    initActionListeners();/*ww  w  .j a va 2s. c  om*/
    replaceOptions_.getItems().addAll(conceptList);
}

From source file:intelligent.wiki.editor.gui.fx.dialogs.ModifyLinkDialog.java

private void initContent() {
    content.add(new Label(i18n.getString("insert-link-dialog.url-label-text")), 0, 0);
    content.add(urlInput, 1, 0);/*from  w w  w . j  av  a 2 s .co  m*/
    GridPane.setHgrow(urlInput, Priority.ALWAYS);

    content.add(new Label(i18n.getString("insert-link-dialog.caption-label-text")), 0, 1);
    content.add(captionInput, 1, 1);
    GridPane.setHgrow(captionInput, Priority.ALWAYS);
}

From source file:gov.va.isaac.gui.listview.operations.ParentRetire.java

@Override
public void init(ObservableList<SimpleDisplayConcept> conceptList) {
    super.init(conceptList);
    root_.add(new Label("Retire as parent"), 0, 0);
    retireAsParent_.setPromptText("-Populate the Concepts List-");
    Node n = ErrorMarkerUtils.setupErrorMarker(retireAsParent_, replaceOptionsInvalidString_);
    root_.add(n, 1, 0);/*from   w  w w. j  a v a 2s .c  om*/

    ComboBoxSetupTool.setupComboBox(retireAsParent_);
    // TODO populate retireAsParentCombo

    retireAsParent_.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(n, Priority.ALWAYS);
    FxUtils.preventColCollapse(root_, 0);

    retireAsParent_.getItems().addListener(new ListChangeListener<SimpleDisplayConcept>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends SimpleDisplayConcept> c) {
            if (retireAsParent_.getItems().size() > 0) {
                replaceOptionsInvalidString_.set(null);
                if (retireAsParent_.getSelectionModel().getSelectedItem() == null) {
                    retireAsParent_.getSelectionModel().selectFirst();
                }
            } else {
                replaceOptionsInvalidString_.set("A concept must be selected from this drop down");
                retireAsParent_.getSelectionModel().clearSelection();
                retireAsParent_.setValue(null);
                retireAsParent_.setPromptText("-Populate the Concepts List-");
            }
        }
    });

    allValid_ = new BooleanBinding() {
        {
            super.bind(replaceOptionsInvalidString_);
        }

        @Override
        protected boolean computeValue() {
            return StringUtils.isBlank(replaceOptionsInvalidString_.get());
        }
    };

}

From source file:org.blockedit.utils.ExceptionDialog.java

/**
 * Create a exception alert that is displayed to the user.
 *
 * @param message The message to show the user
 * @param title The title of the window/*from ww  w .  j av a 2  s.c o  m*/
 * @param header The message header
 * @param exception The exception that triggered this window to be displayed to the user
 * @return A created alert
 */
private static Alert createDialog(String message, String title, String header, Exception exception) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(message);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    String exceptionText = ExceptionUtils.getStackTrace(exception);
    exception.printStackTrace();
    Label label = new Label("The exception stacktrace was:");
    TextArea exceptionArea = new TextArea(
            exceptionText + "\n\n==User Information==\njava.version = " + System.getProperty("java.version")
                    + "\nos.name = " + System.getProperty("os.name") + "\nos.arch = "
                    + System.getProperty("os.arch") + "\nos.version = " + System.getProperty("os.version"));
    exceptionArea.setEditable(false);
    exceptionArea.setWrapText(true);
    exceptionArea.setMaxWidth(UserInformation.getWindowWidth() / 2);
    exceptionArea.setMaxHeight(UserInformation.getWindowHeight() / 2);
    GridPane.setVgrow(exceptionArea, Priority.ALWAYS);
    GridPane.setHgrow(exceptionArea, Priority.ALWAYS);
    GridPane expContent = new GridPane();
    expContent.setMaxWidth(UserInformation.getWindowWidth() / 2);
    expContent.add(label, 0, 0);
    expContent.add(exceptionArea, 0, 1);
    alert.getDialogPane().setExpandableContent(expContent);
    return alert;
}

From source file:com.canoo.dolphin.todo.client.ToDoClient.java

private void showError(String header, String content, Exception e) {
    e.printStackTrace();/*from w w w  .j a va  2s .  c  o  m*/

    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Error");
    alert.setHeaderText(header);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
    System.exit(-1);
}

From source file:jobhunter.gui.dialog.SubscriptionForm.java

public Optional<Action> show() {
    Dialog dlg = new Dialog(null, getTranslation("message.add.subscription"));

    final GridPane content = new GridPane();
    content.setHgap(10);/*w  w  w.  java2  s  .com*/
    content.setVgap(10);

    ObservableList<String> portals = FXCollections.observableArrayList(PreferencesController.getPortalsList());

    portalField.setItems(portals);
    portalField.setPrefWidth(400.0);
    portalField.setEditable(true);

    portalField.setValue(subscription.getPortal());
    portalField.valueProperty().addListener((observable, old, neu) -> {
        subscription.setPortal(neu);
        save.disabledProperty().set(!isValid());
    });

    urlField.setText(subscription.getUri());
    urlField.textProperty().addListener((observable, old, neu) -> {
        subscription.setURI(neu);
        save.disabledProperty().set(!isValid());
    });

    titleField.setText(subscription.getTitle());
    titleField.textProperty().addListener((observable, old, neu) -> {
        subscription.setTitle(neu);
        save.disabledProperty().set(!isValid());
    });

    historyField.setText(subscription.getHistory().toString());
    historyField.textProperty().addListener((observable, old, neu) -> {
        subscription.setHistory(Integer.valueOf(neu));
        save.disabledProperty().set(!isValid());
    });

    content.add(new Label(getTranslation("label.title")), 0, 0);
    content.add(titleField, 1, 0);
    GridPane.setHgrow(titleField, Priority.ALWAYS);

    content.add(new Label(getTranslation("label.portal")), 0, 1);
    content.add(portalField, 1, 1);

    content.add(new Label(getTranslation("label.feed.url")), 0, 2);
    content.add(urlField, 1, 2);
    GridPane.setHgrow(urlField, Priority.ALWAYS);

    content.add(new Label(getTranslation("label.history")), 0, 3);
    content.add(historyField, 1, 3);
    GridPane.setHgrow(historyField, Priority.ALWAYS);

    dlg.setResizable(false);
    dlg.setIconifiable(false);
    dlg.setContent(content);
    dlg.getActions().addAll(save, Dialog.Actions.CANCEL);

    Platform.runLater(() -> titleField.requestFocus());

    l.debug("Showing dialog");
    return Optional.of(dlg.show());
}

From source file:Main.java

private void createControls(GridPane grid) {
    final Label volumeLabel = new Label("Volume");
    final Label rateLabel = new Label("Rate");
    final Label balanceLabel = new Label("Balance");

    GridPane.setHalignment(volumeLabel, HPos.CENTER);
    GridPane.setHalignment(rateLabel, HPos.CENTER);
    GridPane.setHalignment(balanceLabel, HPos.CENTER);

    volumeSlider = new Slider(0.0, 1.0, 1.0);
    rateSlider = new Slider(0.25, 2.5, 1.0);
    balanceSlider = new Slider(-1.0, 1.0, 0.0);

    GridPane.setHgrow(volumeSlider, Priority.ALWAYS);
    GridPane.setHgrow(rateSlider, Priority.ALWAYS);
    GridPane.setHgrow(balanceSlider, Priority.ALWAYS);

    grid.add(volumeLabel, 0, 2);//w w  w  .j  a v  a  2 s. c o  m
    grid.add(volumeSlider, 0, 3);
    grid.add(rateLabel, 1, 2);
    grid.add(rateSlider, 1, 3);
    grid.add(balanceLabel, 2, 2);
    grid.add(balanceSlider, 2, 3);
}