nai*_*jed 5 java javafx javafx-2
有什么方法可以将列约束应用于我的所有 GridPanes 列。我有各种 GridPane 控件,我希望它们共享以下列约束:
<ColumnConstraints hgrow="SOMETIMES" maxWidth="388.0" minWidth="74.0" prefWidth="74.0" />
Run Code Online (Sandbox Code Playgroud)
可以用css来实现吗?
编辑
我最终做了这样的事情。但它不起作用(我的列宽度调整为低于 74),有什么线索吗?
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());
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2985 次 |
| 最近记录: |