繁体   English   中英

JAVAFX如何将Vbox在BorderPane的右侧区域居中

[英]JAVAFX How to center Vbox in right section of BorderPane

我将带有3个按钮的VBox放在BorderPane右侧区域的中央时遇到问题。 有没有办法在FXML或CSS中做到这一点?

更新:

这是FXML中的代码

 <right>
        <VBox id="otherButtons_vbox">
            <Button text="Add automobile"
                    fx:id="addAutomobileButton" onAction="#createAddAutomobileBox"
                    id="other_buttons"/>
            <Button text="Update automobile"
                    fx:id="updateAutomobileButton" onAction="#UpdateAutomobileBox"
                    id="other_buttons"/>
            <Button text="Delete automobile"
                    fx:id="deleteAutomobileButton" onAction="#DeleteAutomobileBox"
                    id="other_buttons"/>
        </VBox>

    </right>

这是CSS文件

#otherButtons_vbox {
            -fx-background-color: black;
            -fx-border-color: red;
            -fx-alignment: center-right;
            -fx-spacing: 10;
            -fx-padding: 10 10 10 10;
            -fx-pref-width: 170;
            -fx-max-height: 190;
}

还有APP的截图。 我希望Vbox位于BorderPate右侧区域的中央。 非常感谢你的回复!

在此处输入图片说明

您可以从fxml执行此操作。 设置VBoxBorderPane.alignment属性:

...
<VBox id="otherButtons_vbox" BorderPane.alignment="CENTER">
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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