[英]JavaFX Hbox of buttons won't fill space of bottom container in BorderPane
我試圖用按鈕填充邊框的底部容器。 根據JavaFX文檔,按鈕應設置為prefHeight,寬度應填充容器。 我將所有子項的maxWidth設置為無窮大,因此我知道子項的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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.