gpt4 book ai didi

JavaFX 概括 GridPane 列约束

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:11:35 26 4
gpt4 key购买 nike

有什么方法可以将列约束应用于我的所有 GridPanes 列。我有各种 GridPane 控件,我希望它们共享以下列约束:

<ColumnConstraints hgrow="SOMETIMES" maxWidth="388.0" minWidth="74.0" prefWidth="74.0" />

可以用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());
}
}
}

最佳答案

在您的 java Controller 代码中,遍历列并设置您需要的任何值。

关于JavaFX 概括 GridPane 列约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12977165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com