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());
}
}
}
在您的java控制器代码中,遍历列并设置您需要的任何值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.