質問

I am using Scene Builder to create my GUI and my menu bar isn't resizing to the parent. How do i get it to do this?

When I try Modify -> Fit to Parent, the menu bar takes up the whole root pane, and obviously this isn't what i want. Here is an image of what i am talking about:

enter image description here

As you can see, the menu bar doesn't fully extend to the end of the window.

役に立ちましたか?

解決 2

I had to set the anchor pane constraints in the menu bar. I had to make the left and right margins zero:

enter image description here

他のヒント

You need to bind the preferred width property of your menu bar to the width of your stage or some other container node. It works when you dynamically resize too.

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

MenuBarHBoxWrappingHere is another way to do it. Wrap MenuBar in a HBOX. Set MenuBar's HGrow to ALWAYS. Set HBOX Node Alignment to TOPLEFT.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top