Is there any way of apply a column constraint to all my GridPanes columns. I have various GridPane controls and I would like them to share the following column constraint:
<ColumnConstraints hgrow="SOMETIMES" maxWidth="388.0" minWidth="74.0" prefWidth="74.0" />
Could it be done using css?
Edit
I ended up doing something like this. But it does not work (my columns width get resized below 74), any clue ?
public static void resizeColumns(Pane parent){
for (Node component : parent.getChildren()) {
if (component instanceof GridPane) {
GridPane gridPane = (GridPane) component;
ObservableList<ColumnConstraints> columnConstraints = gridPane.getColumnConstraints();
for (ColumnConstraints column : columnConstraints) {
column.setMinWidth(74.0);
}
} else if (component instanceof Pane) {
resizeColumns((Pane) component);
} else if (component instanceof ScrollPane) {
resizeColumns((Pane) ((ScrollPane) component).getContent());
}
}
}
In your java controller code, loop through the columns and set whatever values you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With