gpt4 book ai didi

JavaFx:组合框最大宽度

转载 作者:行者123 更新时间:2023-11-30 08:11:59 30 4
gpt4 key购买 nike

我想在GridPane中做:fixed column, liquid column(50%), fixed column, liquid column(50%)。我有以下 FXML:

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

<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60-ea" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane layoutX="100.0" layoutY="74.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" />
<ColumnConstraints hgrow="NEVER" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="ALWAYS" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ComboBox maxWidth="1.7976931348623157E308" GridPane.columnIndex="3" GridPane.hgrow="ALWAYS" />
<Label text="Label" GridPane.columnIndex="2" />
<TextField GridPane.columnIndex="1" GridPane.hgrow="SOMETIMES" />
<Label text="Label" />
<Label text="Label" GridPane.rowIndex="1" />
<TextField maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Label" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<ComboBox maxWidth="1.7976931348623157E308" GridPane.columnIndex="3" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" />
</children>
</GridPane>
</children>
</AnchorPane>

但是,当我关注组合框时,它们会改变大小。例如我在 SB 中开始预览: enter image description here现在我按下组合框上的箭头: enter image description here如您所见,所有布局都已更改。如何解决?

最佳答案

您可以在带有组合框的网格列上使用最小/首选宽度设置。您将 min 和 pref 大小设置为合理的值并保持 maxSize 相同。

这可以防止组合框决定它们需要更大的尺寸并仍然保持“液柱”功能。

关于JavaFx:组合框最大宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30729958/

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