簡體   English   中英

如何將vbox大小設置為最小(包裝內容)

[英]How to set vbox size to be minimum (wrap-content)

我是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的整個屏幕都帶有,並且其中的項目位於top_left上。 我知道我需要將vbox的寬度設置為最小,而不是讓它在邊界窗格中擴展,但是如何?

謝謝 !

感謝這篇文章,我找到了一個解決方案:只需在fxml中添加alignment =“ CENTER” ...

這不是我真正想要的,但這足夠了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM