JavaFX how to access parent-only menu bar?

I use Scene Builder to create my GUI, and my menu bar does not resize the parent. How can i do this?

When I try to change Modify -> Fit to Parent, the menu bar occupies the entire root panel, and obviously this is not what I want. Here is an image of what I'm talking about:

enter image description here

As you can see, the menu bar does not expand to the end of the window.

+4
source share
3 answers

I had to set the bounds of the snap bar in the menu bar. I had to make the left and right fields zero:

enter image description here

+10
source

width node. , .

menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
+13

MenuBarHBoxWrappingHere is another way to do it. Wrap MenuBar in HBOX. Set MenuBar HGrow to ALWAYS. Install HBOX Node Alignment with TOPLEFT.

+2
source

All Articles