Java 如何将vbox大小设置为最小值(包装内容)

Java 如何将vbox大小设置为最小值(包装内容),java,javafx,javafx-8,fxml,Java,Javafx,Javafx 8,Fxml,我是javafx和fxml方面的新手,我无法实现在边框窗格中居中显示我的项目 我的fxml如下所示: <BorderPane ...> <top> <Label styleClass="page-title" text="%startup_title"> <VBox.margin> <Insets bottom="10.0" left="20.0" top="5.

我是javafx和fxml方面的新手,我无法实现在边框窗格中居中显示我的项目

我的fxml如下所示:

<BorderPane ...>
    <top>
        <Label styleClass="page-title" text="%startup_title">
            <VBox.margin>
                <Insets bottom="10.0" left="20.0" top="5.0" />
            </VBox.margin>
         </Label>
    </top>
   <center>
      <VBox fx:id="vbox" >
         <children>
            <ProgressBar fx:id="progressBar" prefWidth="500.0" progress="0.0"  />
            <Label fx:id="progressLabel" styleClass="item-title" text="tt" />
         </children>
      </VBox>
   </center>
</BorderPane>

问题似乎在于vbox有一个完整的屏幕,其中的项目位于左上角。我知道我需要将vbox的宽度设置为最小值,而不是让它在borderpane中展开,但是如何


谢谢大家!

我找到了一个解决方案,原因是:只需在fxml中添加alignment=“CENTER”


这不是我真正想要的,但这已经足够了

alignment=“CENTER”
?是的,谢谢,我想知道在场景生成器中我怎么会错过它。