gpt4 book ai didi

resize - 网格调整大小

转载 作者:行者123 更新时间:2023-12-01 10:57:27 26 4
gpt4 key购买 nike

我想要一个网格面板布局,如附图所示。任何人都知道该怎么做还是我使用了错误的布局? enter image description here

最佳答案

您可以使用列和行约束来控制 GridPane 中不同行和列的增长方式。

这样做的方法是将第一列的 hgrow 属性设置为 ALWAYS,并将第一行的 vgrow 属性设置为 ALWAYS - 这意味着顶部左侧单元格将始终展开。您可以将其他单元格设置为固定的宽度/高度,否则它们将展开以适应其内容,而不会更多。

我已经包含了一个 FXML 示例,GridPane 位于 AnchorPane 内,并锚定在 AnchorPane 的顶部、左下角和右侧。这意味着 GridPane 将增长以填充父 AnchorPane:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" />
<ColumnConstraints prefWidth="150" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="ALWAYS" />
<RowConstraints prefHeight="150" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>

这会产生此处所示的布局,并展开以填充父 Pane :

Resulting Layout

关于resize - 网格调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14390261/

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