按钮的 JavaFX Hbox 不会填充 BorderPane 中底部容器的 space
JavaFX Hbox of buttons won't fill space of bottom container in BorderPane
我正在尝试用按钮填充边框的底部容器。根据 JavaFX 文档,按钮应设置为 prefHeight,宽度应填满容器。我将所有 children 的 maxWidth 设置为无穷大,因此我知道 children 的 maxWidth 不会阻止调整大小。请参阅下面的 fxml。
<BorderPane>
<top>
<VBox>
<Label text="This is a message"/>
<HBox>
<TextField>Text 1</TextField>
<TextField>Text 2</TextField>
<TextField>Text 3</TextField>
</HBox>
</VBox>
</top>
<center>
<TableView>
</TableView>
</center>
<bottom>
<HBox maxWidth="Infinity">
<Button maxWidth="Infinity">Button 1</Button>
<Button maxWidth="Infinity">Button 2</Button>
<Button maxWidth="Infinity">Button 3</Button>
<Button maxWidth="Infinity">Button 4</Button>
<Button maxWidth="Infinity">Button 5</Button>
</HBox>
</bottom>
</BorderPane>
hgrow 将为子节点设置水平增长优先级。 P
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane xmlns="http://javafx.com/javafx/8">
<top>
<VBox>
<children>
<Label text="This is a message" />
<HBox>
<children>
<TextField>Text 1</TextField>
<TextField>Text 2</TextField>
<TextField>Text 3</TextField>
</children>
</HBox>
</children>
</VBox>
</top>
<center>
<TableView>
</TableView>
</center>
<bottom>
<HBox maxWidth="Infinity">
<children>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 1</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 2</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 3</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 4</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 5</Button>
</children>
</HBox>
</bottom>
</BorderPane>
我正在尝试用按钮填充边框的底部容器。根据 JavaFX 文档,按钮应设置为 prefHeight,宽度应填满容器。我将所有 children 的 maxWidth 设置为无穷大,因此我知道 children 的 maxWidth 不会阻止调整大小。请参阅下面的 fxml。
<BorderPane>
<top>
<VBox>
<Label text="This is a message"/>
<HBox>
<TextField>Text 1</TextField>
<TextField>Text 2</TextField>
<TextField>Text 3</TextField>
</HBox>
</VBox>
</top>
<center>
<TableView>
</TableView>
</center>
<bottom>
<HBox maxWidth="Infinity">
<Button maxWidth="Infinity">Button 1</Button>
<Button maxWidth="Infinity">Button 2</Button>
<Button maxWidth="Infinity">Button 3</Button>
<Button maxWidth="Infinity">Button 4</Button>
<Button maxWidth="Infinity">Button 5</Button>
</HBox>
</bottom>
</BorderPane>
hgrow 将为子节点设置水平增长优先级。 P
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane xmlns="http://javafx.com/javafx/8">
<top>
<VBox>
<children>
<Label text="This is a message" />
<HBox>
<children>
<TextField>Text 1</TextField>
<TextField>Text 2</TextField>
<TextField>Text 3</TextField>
</children>
</HBox>
</children>
</VBox>
</top>
<center>
<TableView>
</TableView>
</center>
<bottom>
<HBox maxWidth="Infinity">
<children>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 1</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 2</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 3</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 4</Button>
<Button maxWidth="Infinity" HBox.hgrow="ALWAYS">Button 5</Button>
</children>
</HBox>
</bottom>
</BorderPane>