【发布时间】:2016-02-24 00:54:10
【问题描述】:
我无法真正理解这种拉伸在 JavaFX 中是如何工作的。对于 HBox 和 TextField,我的 prefWidth 为 Infinity,所以如果我们调整框架的大小,TextField 应该更大。请帮助我,我在这里缺少什么。谢谢。
<GridPane fx:id="first" hgap="5" vgap="5" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" >
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" percentWidth="100.0" />
</columnConstraints>
<VBox.margin>
<Insets left="10.0" top="15"/>
</VBox.margin>
<HBox GridPane.columnIndex="0" GridPane.rowIndex="0" prefWidth="Infinity" maxWidth="Infinity">
<fx:define>
<ToggleGroup fx:id="myToggleGroup"/>
</fx:define>
<children>
<RadioButton text="System" toggleGroup="$myToggleGroup">
</RadioButton>
<RadioButton text="Document" toggleGroup="$myToggleGroup">
<HBox.margin>
<Insets left="200.0"/>
</HBox.margin>
</RadioButton>
</children>
</HBox>
<HBox GridPane.rowIndex="1" GridPane.columnIndex="0" >
<Label text="Name:" minWidth="50">
</Label>
<TextField maxWidth="Infinity" minWidth="450" prefWidth="Infinity">
<HBox.margin>
<Insets left="20.0"/>
</HBox.margin>
</TextField>
</HBox>
【问题讨论】:
-
看看stackoverflow.com/questions/35438104/…(不同,但对网格窗格中的布局如何工作有完整的解释)是否有帮助。
-
另外我只能在这个项目中使用fxml。
-
没关系,该问题中的所有内容也可以使用FXML完成。 (虽然,“only 允许使用 FXML”???不能只用 FXML 编写应用程序,控制器中需要 Java。)
-
是的,我只指 GUI。
标签: javafx