Java Code Examples for javafx.scene.layout.GridPane#setPrefWidth()

The following examples show how to use javafx.scene.layout.GridPane#setPrefWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TradeSubView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void buildViews() {
    addLeftBox();
    addContentPane();

    leftGridPane = new GridPane();
    leftGridPane.setPrefWidth(340);
    leftGridPane.setHgap(Layout.GRID_GAP);
    leftGridPane.setVgap(Layout.GRID_GAP);
    VBox.setMargin(leftGridPane, new Insets(0, 10, 10, 10));
    leftVBox.getChildren().add(leftGridPane);

    leftGridPaneRowIndex = 0;
    tradeProcessTitledGroupBg = addTitledGroupBg(leftGridPane, leftGridPaneRowIndex, 1, Res.get("portfolio.pending.tradeProcess"));
    tradeProcessTitledGroupBg.getStyleClass().add("last");

    addWizards();

    TitledGroupBg titledGroupBg = addTitledGroupBg(leftGridPane, leftGridPaneRowIndex, 1, "", 30);
    titledGroupBg.getStyleClass().add("last");
    Label label = addMultilineLabel(leftGridPane, leftGridPaneRowIndex, "", 30);
    AutoTooltipButton button = (AutoTooltipButton) addButtonAfterGroup(leftGridPane, ++leftGridPaneRowIndex, "");
    tradeStepInfo = new TradeStepInfo(titledGroupBg, label, button);
}
 
Example 2
Source File: ProofOfBurnVerificationWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@Override
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints = new ColumnConstraints();
    columnConstraints.setPercentWidth(100);
    gridPane.getColumnConstraints().add(columnConstraints);
}
 
Example 3
Source File: ProofOfBurnSignatureWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@Override
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints = new ColumnConstraints();
    columnConstraints.setPercentWidth(100);
    gridPane.getColumnConstraints().add(columnConstraints);
}
 
Example 4
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}
 
Example 5
Source File: PluginParametersPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public Pane getParamPane(final PluginParametersNode node) {
    if (node.getChildren().isEmpty()) {
        return null;
    }
    currentCol = 0;
    paramGroupGridPane = new GridPane();

    final PluginParametersNode firstChild = node.getChildren().get(0);
    final Pane firstPane = firstChild.getFormatter().getParamPane(firstChild);
    final Button firstButton = firstChild.getFormatter().getParamHelp(firstChild);
    addElements(firstChild, firstPane, firstButton);
    HBox.setHgrow(firstPane, shouldHGrow ? Priority.ALWAYS : Priority.NEVER);
    if (firstButton != null) {
        HBox.setMargin(firstButton, new Insets(0, PADDING, 0, 0));
    }

    for (PluginParametersNode child : node.getChildren().subList(1, node.getChildren().size() - 1)) {
        final LabelDescriptionBox label = child.getFormatter().getParamLabel(child);
        label.setStyle("-fx-label-padding: " + -PADDING);
        final Pane paramPane = child.getFormatter().getParamPane(child);
        final Button paramHelp = child.getFormatter().getParamHelp(child);
        label.bindDescriptionToLabel();
        label.setMinWidth(USE_PREF_SIZE);
        addElements(child, label, paramPane, paramHelp);
        HBox.setHgrow(paramPane, shouldHGrow ? Priority.ALWAYS : Priority.NEVER);
        if (paramHelp != null) {
            HBox.setMargin(paramHelp, new Insets(0, PADDING, 0, 0));
        }
    }

    final PluginParametersNode lastChild = node.getChildren().get(node.getChildren().size() - 1);
    final LabelDescriptionBox lastLabel = lastChild.getFormatter().getParamLabel(lastChild);
    lastLabel.setStyle("-fx-label-padding: " + -PADDING);
    lastLabel.bindDescriptionToLabel();
    lastLabel.setMinWidth(USE_PREF_SIZE);
    final Pane lastPane = lastChild.getFormatter().getParamPane(lastChild);
    addElements(lastChild, lastLabel, lastPane);
    HBox.setHgrow(lastPane, shouldHGrow ? Priority.ALWAYS : Priority.NEVER);
    paramGroupGridPane.setPrefWidth(0);
    return paramGroupGridPane;
}
 
Example 6
Source File: AddComponentAction.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public AddComponentDialog(final AlarmTreeItem<?> parent)
{
    final GridPane layout = new GridPane();
    // layout.setGridLinesVisible(true);
    layout.setHgap(5);
    layout.setVgap(5);

    layout.add(new Label("Type:"), 0, 0);

    final ToggleGroup types = new ToggleGroup();
    type_node.setToggleGroup(types);
    type_node.setTooltip(new Tooltip("Create a new node in the alarm configuration hierachy"));

    type_pv.setToggleGroup(types);
    type_pv.setTooltip(new Tooltip("Add a PV or a list of space-separated PVs to the alarm configuration"));

    layout.add(new HBox(5, type_node, type_pv), 1, 0);

    // For 'main' and the 'subsystem' level suggest adding another node.
    // Further below, suggest PV
    if (parent.getParent() == null ||
        parent.getParent().getParent() == null)
        type_node.setSelected(true);
    else
        type_pv.setSelected(true);

    layout.add(new Label("Name:"), 0, 1);
    name.setTooltip(new Tooltip("Name of new node or PV"));
    GridPane.setHgrow(name, Priority.ALWAYS);
    layout.add(name, 1, 1);

    layout.add(message, 1, 2);

    name.textProperty().addListener( (prop, old, value) -> checkName(value));

    setTitle("Add Component to " + parent.getPathName());
    getDialogPane().setContent(layout);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    setResizable(true);

    layout.setPrefWidth(600);

    setResultConverter(button ->
        button == ButtonType.OK ? name.getText() : null);

    // Initial focus on name
    Platform.runLater(() -> name.requestFocus());

    type_pv.selectedProperty().addListener(p ->
    {
        updateAutocompletion();
        // Selecting a type then also focuses on the name
        Platform.runLater(() -> name.requestFocus());
    });
    // Initial setting
    updateAutocompletion();
}
 
Example 7
Source File: AlertHelper.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
static Alert buildDeleteAlertDialog(List<Path> pathsLabel) {
    Alert deleteAlert = new WindowModalAlert(Alert.AlertType.WARNING, null, ButtonType.YES, ButtonType.CANCEL);
    deleteAlert.setHeaderText("Do you want to delete selected path(s)?");
    DialogPane dialogPane = deleteAlert.getDialogPane();

    ObservableList<Path> paths = Optional.ofNullable(pathsLabel)
            .map(FXCollections::observableList)
            .orElse(FXCollections.emptyObservableList());

    if (paths.isEmpty()) {
        dialogPane.setContentText("There are no files selected.");
        deleteAlert.getButtonTypes().clear();
        deleteAlert.getButtonTypes().add(ButtonType.CANCEL);
        return deleteAlert;
    }

    ListView<Path> listView = new ListView<>(paths);
    listView.setId("listOfPaths");

    GridPane gridPane = new GridPane();
    gridPane.addRow(0, listView);
    GridPane.setHgrow(listView, Priority.ALWAYS);

    double minWidth = 200.0;
    double maxWidth = Screen.getScreens().stream()
            .mapToDouble(s -> s.getBounds().getWidth() / 3)
            .min().orElse(minWidth);

    double prefWidth = paths.stream()
            .map(String::valueOf)
            .mapToDouble(s -> s.length() * 7)
            .max()
            .orElse(maxWidth);

    double minHeight = IntStream.of(paths.size())
            .map(e -> e * 70)
            .filter(e -> e <= 300 && e >= 70)
            .findFirst()
            .orElse(200);

    gridPane.setMinWidth(minWidth);
    gridPane.setPrefWidth(prefWidth);
    gridPane.setPrefHeight(minHeight);
    dialogPane.setContent(gridPane);
    return deleteAlert;
}