0

So I'm trying to add multiple Nodes in one Row of a GridPane with sizes in percentages. This is the UI, with the Grid Lines visible: enter image description here

When the user clicks the Checkbox for "Check Editbuffer Checksum", I want to display a ComboBox next to Checkbox in the same Row and Colum. My problem is, that the Combobox fits the entire Cell, so the Checkbox is not visible anymore. Basically, it should look like this: enter image description here

And if the user deselects the Checkbox the ComboBox should disappear again. This is the code to create the GridPane:

private void fill() {
    getChildren().clear();
    getRowConstraints().clear();

    setMinWidth(350);
    setPadding(new Insets(17));
    setVgap(5);
    setHgap(5);

    lTitle.setAlignment(Pos.CENTER);
    fxAssign.setMaxWidth(Double.MAX_VALUE);

    RowConstraints heigthPadding = new RowConstraints();
    heigthPadding.setPercentHeight(40);
    add(lTitle, 0, 0, 2, 1);
    getRowConstraints().add(heigthPadding);

    addRow(1, lName, fxName);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));
    addRow(2, lRequest, fxRequest);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));
    addRow(3, lHeader, fxHeader);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));
    addRow(4, lLength, fxLength);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));
    addRow(5, lForm, fxForm);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));
    addRow(6, lCheck, fxCheck);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));

    add(fxAssign, 0, 7, 2, 1);
    getRowConstraints().add(new RowConstraints(ROW_HEIGHT));

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setPercentWidth(50);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setPercentWidth(50);
    getColumnConstraints().add(columnConstraints1);
    getColumnConstraints().add(columnConstraints2);

    setGridLinesVisible(true);
}
codeNoob
  • 21
  • 2
  • 4
    Well just put in the cell `HBox` with the two controls in the corresponding cell and bind the `ComboBox`::`visibileProperty` to the `CheckBox`::`selectedProperty`. – mr mcwolf Sep 25 '22 at 17:44
  • Thanks, that worked! Was thinking it had to be more complex lol. – codeNoob Sep 25 '22 at 18:22

0 Answers0