繁体   English   中英

JavaFX Hbox按钮不会填充BorderPane中底部容器的空间

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM