Reputation: 101
I'm trying to make an window, where I have StackPane as root and I want to add MenuBar to this window. However MenuBar is in the center of the screen and I want to keep it in the top part of the window as in normal Windows applications.
root = new StackPane();
root.getChildren().add(new MenuBar());
this will show window like this http://i61.tinypic.com/2pzblmo.jpg
Thanks you for your advice!
Upvotes: 1
Views: 2380
Reputation: 46
I would say StackPane is not suitable for making a GUI including a menubar. StackPane will just put the controls you add to it one on top of the other. In java docs you can find: "StackPane
The StackPane layout pane places all of the nodes within a single stack with each new node added on top of the previous node. This layout model provides an easy way to overlay text on a shape or image or to overlap common shapes to create a complex shape. Figure 1-6 shows a help icon that is created by stacking a question mark on top of a rectangle with a gradient background. "
Upvotes: 2