My hbox does not fit into my top borderpane. I dynamically entered my hbox like this:
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? Can I do it via scenebuilder or by code? Here is what it looks like:
Thank you in advance.
It looks like there is the maxWidth="595.0"
attribute in your <JFXHamburger...>
element. Just remove it and HBox.hgrow="ALWAYS"
will work as expected.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.