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:org.jacp.demo.components.ContactChartViewComponent.java

private GridPane createRoot() {
    final GridPane myRoot = new GridPane();
    myRoot.getStyleClass().addAll("dark", "bar-chart-root");
    myRoot.setAlignment(Pos.CENTER);/*from   w  w w.jav a 2  s .c  om*/
    GridPane.setHgrow(myRoot, Priority.ALWAYS);
    GridPane.setVgrow(myRoot, Priority.ALWAYS);
    return myRoot;
}

From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginTextFieldProperty.java

public PreferencesPluginTextFieldProperty(Label label, boolean emptyStringAllowed) {
    super(label, new TextField(), new SimpleStringProperty(), null, // validator handled below
            new StringConverter<String>() {
                @Override/*ww  w  .  j  a v a2  s.  c  om*/
                public String convertToString(String value) {
                    return value != null ? value.toString() : null;
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getProperty().bind(property.getControl().textProperty());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getControl().textProperty().set(property.readFromPersistedPreferences());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    GridPane.setHgrow(property.getLabel(), Priority.NEVER);
                    GridPane.setFillWidth(property.getControl(), true);
                    GridPane.setHgrow(property.getControl(), Priority.ALWAYS);
                }
            });
    validator = new ValidBooleanBinding() {
        {
            bind(getProperty());
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (!emptyStringAllowed && StringUtils.isBlank(getProperty().getValue())) {
                this.setInvalidReason("unspecified value for " + name);
                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }

            this.clearInvalidReason();

            return true;
        }
    };
}

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

protected BarChart<String, Number> createChart() {

    this.xAxis = new CategoryAxis();
    this.yAxis = new NumberAxis();
    this.yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(this.yAxis, "$", null));
    this.bc = new BarChart<String, Number>(this.xAxis, this.yAxis);
    this.bc.setAnimated(true);
    this.bc.setTitle(" ");

    this.xAxis.getStyleClass().add("jacp-bar");
    this.yAxis.getStyleClass().add("jacp-bar");
    this.xAxis.setLabel("Year");
    this.yAxis.setLabel("Price");

    this.series1 = new XYChart.Series<String, Number>();
    this.series1.setName("electronic");
    this.series2 = new XYChart.Series<String, Number>();
    this.series2.setName("clothes");
    this.series3 = new XYChart.Series<String, Number>();
    this.series3.setName("hardware");
    this.series4 = new XYChart.Series<String, Number>();
    this.series4.setName("books");

    GridPane.setHalignment(this.bc, HPos.CENTER);
    GridPane.setVgrow(this.bc, Priority.ALWAYS);
    GridPane.setHgrow(this.bc, Priority.ALWAYS);
    GridPane.setMargin(this.bc, new Insets(0, 6, 0, 0));
    return this.bc;
}

From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginComboBoxProperty.java

/**
 * @param name//from   www .  j a v a  2  s .c  o m
 * @param stringConverter
 * 
 * Constructor for ComboBox that displays a String
 * that must be derived/converted from its underlying value
 * 
 * Allows a preexisting Label to be used
 */
protected PreferencesPluginComboBoxProperty(Label label, StringConverter<T> stringConverter) {
    super(label, new ComboBox<T>(), new SimpleObjectProperty<T>(), null, // validator handled below
            stringConverter, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    property.getProperty()
                            .bind(property.getControl().getSelectionModel().selectedItemProperty());
                }
            }, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    property.getControl().getSelectionModel().select(property.readFromPersistedPreferences());
                }
            }, new PropertyAction<T, ComboBox<T>>() {
                @Override
                public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) {
                    GridPane.setHgrow(property.getLabel(), Priority.NEVER);
                    GridPane.setFillWidth(property.getControl(), true);
                    GridPane.setHgrow(property.getControl(), Priority.ALWAYS);
                }
            });
    validator = new ValidBooleanBinding() {
        {
            bind(getProperty());
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (getProperty().getValue() == null) {
                this.setInvalidReason("null/unset/unselected " + name);

                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }
            if (StringUtils.isEmpty(getStringConverter().convertToString(getProperty().getValue()))) {
                this.setInvalidReason("Invalid " + name);

                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }

            this.clearInvalidReason();
            return true;
        }
    };

    control.setCellFactory(new Callback<ListView<T>, ListCell<T>>() {
        @Override
        public ListCell<T> call(ListView<T> param) {
            final ListCell<T> cell = new ListCell<T>() {
                @Override
                protected void updateItem(T c, boolean emptyRow) {
                    super.updateItem(c, emptyRow);

                    if (c == null) {
                        setText(null);
                    } else {
                        String diplay = getStringConverter().convertToString(c);
                        setText(diplay);
                    }
                }
            };

            return cell;
        }
    });
    control.setButtonCell(new ListCell<T>() {
        @Override
        protected void updateItem(T c, boolean emptyRow) {
            super.updateItem(c, emptyRow);
            if (emptyRow) {
                setText("");
            } else {
                String diplay = getStringConverter().convertToString(c);
                setText(diplay);
            }
        }
    });
}

From source file:Main.java

private void createClipList(GridPane grid) {
    final VBox vbox = new VBox(30);
    vbox.setAlignment(Pos.TOP_CENTER);/*w w  w .  ja  va  2  s .c om*/

    final Label clipLabel = new Label("Code Monkey To-Do List:");
    clipLabel.setId("clipLabel");

    final Button getUpButton = new Button("Get Up, Get Coffee");
    getUpButton.setPrefWidth(300);
    getUpButton.setOnAction(createPlayHandler(coffeeClip));

    final Button goToJobButton = new Button("Go to Job");
    goToJobButton.setPrefWidth(300);
    goToJobButton.setOnAction(createPlayHandler(jobClip));

    final Button meetingButton = new Button("Have Boring Meeting");
    meetingButton.setPrefWidth(300);
    meetingButton.setOnAction(createPlayHandler(meetingClip));

    final Hyperlink link = new Hyperlink("About Code Monkey...");
    link.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            WebView wv = new WebView();
            wv.getEngine().load("http://www.jonathancoulton.com/2006/04/14/" + "thing-a-week-29-code-monkey/");

            Scene scene = new Scene(wv, 720, 480);

            Stage stage = new Stage();
            stage.setTitle("Code Monkey");
            stage.setScene(scene);
            stage.show();
        }
    });

    vbox.getChildren().addAll(clipLabel, getUpButton, goToJobButton, meetingButton, link);

    GridPane.setHalignment(vbox, HPos.CENTER);
    GridPane.setHgrow(vbox, Priority.ALWAYS);
    GridPane.setVgrow(vbox, Priority.ALWAYS);
    grid.add(vbox, 0, 0, GridPane.REMAINING, 1);
}

From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java

private Parent createLegendPane() {

    GridPane legendPane = new GridPane();
    legendPane.setPadding(new Insets(5, 5, 5, 5));
    int columnCount = 3;
    int currentRow = 0;
    int currentColumn = 0;
    for (UpdateFileNamesPlaceholder placeholder : UpdateFileNamesPlaceholder.values()) {

        StringBuilder placeholderText = new StringBuilder();
        placeholderText.append("${").append(placeholder.getPlaceholder()).append("}: ");
        placeholderText.append(placeholder.resolveLocalization(this.getLocalization()));

        Label placeholderLabel = new Label(placeholderText.toString());
        placeholderLabel.setMaxWidth(Double.MAX_VALUE);
        placeholderLabel.setPadding(new Insets(3, 3, 3, 3));
        placeholderLabel.setAlignment(Pos.TOP_LEFT);
        legendPane.add(placeholderLabel, currentColumn, currentRow);
        GridPane.setFillWidth(placeholderLabel, Boolean.TRUE);
        GridPane.setHgrow(placeholderLabel, Priority.ALWAYS);

        currentColumn++;//w  w w.  j a  v  a 2s .  c  o m
        if (currentColumn >= columnCount) {
            currentRow++;
            currentColumn = 0;
        }

    }

    TitledPane legendTitlePane = new TitledPane(this.getLocalization().legend(), legendPane);
    legendTitlePane.setCollapsible(false);
    return legendTitlePane;

}

From source file:se.trixon.filebydate.ui.ProfilePanel.java

private void createUI() {
    //setGridLinesVisible(true);

    Label nameLabel = new Label(Dict.NAME.toString());
    Label descLabel = new Label(Dict.DESCRIPTION.toString());
    Label filePatternLabel = new Label(Dict.FILE_PATTERN.toString());
    Label dateSourceLabel = new Label(Dict.DATE_SOURCE.toString());
    mDatePatternLabel = new Label(Dict.DATE_PATTERN.toString());
    Label operationLabel = new Label(Dict.OPERATION.toString());
    Label caseBaseLabel = new Label(Dict.BASENAME.toString());
    Label caseExtLabel = new Label(Dict.EXTENSION.toString());

    mLinksCheckBox = new CheckBox(Dict.FOLLOW_LINKS.toString());
    mRecursiveCheckBox = new CheckBox(Dict.RECURSIVE.toString());
    mReplaceCheckBox = new CheckBox(Dict.REPLACE.toString());

    mCaseBaseComboBox = new ComboBox<>();
    mDatePatternComboBox = new ComboBox<>();
    mDateSourceComboBox = new ComboBox<>();
    mFilePatternComboBox = new ComboBox<>();
    mOperationComboBox = new ComboBox<>();
    mCaseExtComboBox = new ComboBox<>();

    mNameTextField = new TextField();
    mDescTextField = new TextField();

    mSourceChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.SOURCE.toString(), ObjectMode.DIRECTORY,
            SelectionMode.SINGLE);//from w ww.  ja v a  2s . c  o  m
    mDestChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.DESTINATION.toString(),
            ObjectMode.DIRECTORY, SelectionMode.SINGLE);

    mFilePatternComboBox.setEditable(true);
    mDatePatternComboBox.setEditable(true);
    //mDatePatternLabel.setPrefWidth(300);

    int col = 0;
    int row = 0;

    add(nameLabel, col, row, REMAINING, 1);
    add(mNameTextField, col, ++row, REMAINING, 1);
    add(descLabel, col, ++row, REMAINING, 1);
    add(mDescTextField, col, ++row, REMAINING, 1);
    add(mSourceChooserPane, col, ++row, REMAINING, 1);
    add(mDestChooserPane, col, ++row, REMAINING, 1);

    GridPane patternPane = new GridPane();
    patternPane.addRow(0, filePatternLabel, dateSourceLabel, mDatePatternLabel);
    patternPane.addRow(1, mFilePatternComboBox, mDateSourceComboBox, mDatePatternComboBox);
    patternPane.setHgap(8);
    addRow(++row, patternPane);

    GridPane.setHgrow(mFilePatternComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDateSourceComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDatePatternComboBox, Priority.ALWAYS);

    GridPane.setFillWidth(mFilePatternComboBox, true);
    GridPane.setFillWidth(mDateSourceComboBox, true);
    GridPane.setFillWidth(mDatePatternComboBox, true);

    double width = 100.0 / 3.0;
    ColumnConstraints col1 = new ColumnConstraints();
    col1.setPercentWidth(width);
    ColumnConstraints col2 = new ColumnConstraints();
    col2.setPercentWidth(width);
    ColumnConstraints col3 = new ColumnConstraints();
    col3.setPercentWidth(width);
    patternPane.getColumnConstraints().addAll(col1, col2, col3);

    mFilePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    mDateSourceComboBox.setMaxWidth(Double.MAX_VALUE);
    mDatePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    GridPane subPane = new GridPane();
    //subPane.setGridLinesVisible(true);
    subPane.addRow(0, operationLabel, new Label(), new Label(), new Label(), caseBaseLabel, caseExtLabel);
    subPane.addRow(1, mOperationComboBox, mLinksCheckBox, mRecursiveCheckBox, mReplaceCheckBox,
            mCaseBaseComboBox, mCaseExtComboBox);
    subPane.setHgap(8);
    add(subPane, col, ++row, REMAINING, 1);

    final Insets rowInsets = new Insets(0, 0, 8, 0);

    GridPane.setMargin(mNameTextField, rowInsets);
    GridPane.setMargin(mDescTextField, rowInsets);
    GridPane.setMargin(mSourceChooserPane, rowInsets);
    GridPane.setMargin(mDestChooserPane, rowInsets);
    GridPane.setMargin(patternPane, rowInsets);

    mFilePatternComboBox.setItems(FXCollections.observableArrayList("*", "{*.jpg,*.JPG}", "{*.mp4,*.MP4}"));

    mDatePatternComboBox.setItems(FXCollections.observableArrayList("yyyy/MM/yyyy-MM-dd",
            "yyyy/MM/yyyy-MM-dd/HH", "yyyy/MM/dd", "yyyy/ww", "yyyy/ww/u"));

    mCaseBaseComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mCaseExtComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mDateSourceComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(DateSource.values())));
    mOperationComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Command.COPY, Command.MOVE)));
}

From source file:org.jacp.demo.perspectives.ContactPerspective.java

private void createPerspectiveLayout(final PerspectiveLayout perspectiveLayout) {

    // bind width and height to ensure that the gridpane is always on
    // fullspan!/*w ww.j a  v  a  2s.  c om*/
    chartView.minWidthProperty().bind(chartAnchor.widthProperty());
    chartView.minHeightProperty().bind(chartAnchor.heightProperty());

    detailView.minWidthProperty().bind(detailAnchor.widthProperty());
    detailView.minHeightProperty().bind(detailAnchor.heightProperty());

    GridPane.setVgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);
    GridPane.setHgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);
    perspectiveLayout.registerTargetLayoutComponent("PleftMenu", gridPane1);
    // register main content Top
    perspectiveLayout.registerTargetLayoutComponent(this.topId, gridPane2);
    // register main content Bottom
    perspectiveLayout.registerTargetLayoutComponent(this.bottomId, chartView);
    perspectiveLayout.registerTargetLayoutComponent(this.detailId, detailView);
}

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

@Override
public void init(ObservableList<SimpleDisplayConcept> conceptList) {
    root.setHgap(10);//  w w w  . j a v a2 s  .c  om
    root.setVgap(10);

    super.init(conceptList);

    String date = new SimpleDateFormat("MM-dd-yyyy HH-mm-ss").format(new Date());
    fileName = "VA_USCRS_Submission_File_" + date;

    //this.chooseFileName(); TODO: Finish the file name system
    fileChooser.setTitle("Save USCRS Concept Request File");
    fileChooser.getExtensionFilters().addAll(new ExtensionFilter("Excel Files .xls .xlsx", "*.xls", "*.xlsx"));
    fileChooser.setInitialFileName(fileName);
    //      outputProperty.set(outputField.textProperty());

    openFileChooser.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent e) {
            file = fileChooser.showSaveDialog(null);
            if (file != null) {
                if (file.getAbsolutePath() != null && file.getAbsolutePath() != "") {
                    outputField.setText(file.getAbsolutePath());
                    filePath = file.getAbsolutePath();
                    logger_.info("File Path Changed: " + filePath);
                }
            }
        }
    });
    outputField.setOnAction( //TODO: So you can manually type in a file path and it validates (break this out)
            new EventHandler<ActionEvent>() {
                @Override
                public void handle(final ActionEvent e) {
                    filePath = outputField.getText();
                    file = new File(filePath);
                }
            });

    allFieldsValid = new ValidBooleanBinding() {
        {
            bind(outputField.textProperty());
            setComputeOnInvalidate(true);
        }

        /* (non-Javadoc)
         * @see javafx.beans.binding.BooleanBinding#computeValue()
         */
        @Override
        protected boolean computeValue() {
            if (outputField.getText() != "" || !outputField.getText().trim().isEmpty()) {
                String fieldOutput = outputField.getText();
                if (filePath != null && !fieldOutput.isEmpty() && file != null) //fieldOutput is repetetive but necessary
                {
                    int lastSeperatorPosition = outputField.getText().lastIndexOf(File.separator);
                    String path = "";
                    if (lastSeperatorPosition > 0) {
                        path = outputField.getText().substring(0, lastSeperatorPosition);
                    } else {
                        path = outputField.getText();
                    }

                    logger_.debug("Output Directory: " + path);
                    File f = new File(path);
                    if (file.isFile()) { //If we want to prevent file overwrite
                        this.setInvalidReason("The file " + filePath + " already exists");
                        return false;
                    } else if (f.isDirectory()) {
                        return true;
                    } else {
                        this.setInvalidReason("Output Path is not a directory");
                        return false;
                    }
                } else {
                    this.setInvalidReason("File Output Directory is not set - output field null!!");
                    return false;
                }
            } else {
                this.setInvalidReason("Output field is empty, output directory is not set");
                return false;
            }
        }
    };

    root.add(openFileChooser, 2, 0);
    GridPane.setHalignment(openFileChooser, HPos.LEFT);

    Label outputLocationLabel = new Label("Output Location");
    root.add(outputLocationLabel, 0, 0);

    GridPane.setHalignment(outputLocationLabel, HPos.LEFT);

    StackPane sp = ErrorMarkerUtils.setupErrorMarker(outputField, null, allFieldsValid);
    root.add(sp, 1, 0);
    GridPane.setHgrow(sp, Priority.ALWAYS);
    GridPane.setHalignment(sp, HPos.LEFT);

    Label datePickerLabel = new Label("Export Date Filter");
    root.add(datePickerLabel, 0, 1);
    GridPane.setHalignment(datePickerLabel, HPos.LEFT);
    root.add(datePicker, 1, 1);

    Label allDatesLabel = new Label("Export All Concepts");
    root.add(allDatesLabel, 0, 2);
    skipFilterCheckbox.setText("Export All Concepts (No Filters)");
    skipFilterCheckbox.setSelected(false);
    root.add(skipFilterCheckbox, 1, 2);

    super.root_ = root;
}

From source file:pah9qdmoviereviews.MovieReviewsFXMLController.java

public void displayExceptionAlert(Exception ex) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception");
    alert.setHeaderText("An Exception Occurred!");
    alert.setContentText(//from ww  w  .  j av  a  2 s.c o  m
            "An exception occurred.  View the exception information below by clicking Show Details.");

    // Create expandable Exception.
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.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);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}