简体   繁体   English

hbox不适合borderpane顶部

[英]hbox does not fit borderpane top

My hbox does not fit into my top borderpane. 我的hbox不适合我的顶部边框。 I dynamically entered my hbox like this: 我像这样动态输入我的hbox:

URL hBoxUrl = getClass().getResource("/gui/views/HamburgerMenu.fxml");           
loader.setLocation(hBoxUrl);
HBox hBox = loader.load();

rootLayout.setTop(hBox);

Is there any solution so that my hbox will fit my top borderpane? 有什么解决方案可以使我的hbox适应顶部边框吗? Can I do it via scenebuilder or by code? 我可以通过scenebuilder还是通过代码来完成? Here is what it looks like: 看起来像这样: 在此处输入图片说明

Thank you in advance. 先感谢您。

It looks like there is the maxWidth="595.0" attribute in your <JFXHamburger...> element. 看起来您的<JFXHamburger...>元素中有maxWidth="595.0"属性。 Just remove it and HBox.hgrow="ALWAYS" will work as expected. 只需将其删除, HBox.hgrow="ALWAYS"将按预期工作。

Example: 例:

<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXHamburger?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>

<BorderPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml">
    <top>
        <HBox>
            <JFXHamburger HBox.hgrow="ALWAYS" alignment="CENTER_LEFT" style="-fx-background-color: lightblue;">
                <padding>
                    <Insets bottom="5.0" left="15.0" right="15.0" top="5.0" />
                </padding>
            </JFXHamburger>
        </HBox>
    </top>
    <center>
        <Pane prefHeight="400.0" prefWidth="800.0">

        </Pane>
    </center>
</BorderPane>

在此处输入图片说明

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

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