-1

Picture of my application now

I would like to have "Tools" in the menubar to align right but I've searched a lot on the internet and could not find anything useful so I'm trying it here. The next thing I wanted to fix and did not find is Gridpane which is not filling its parent's size. If any of you know the properties or code to make this happen. Let me know!

  public MyMenuBar(StackPane root) {
menu1 = new Menu("KunstwerkLijst");
  menuItem1 = new MenuItem("Lijst van kunstwerken");
    menuItem1.setOnAction(event ->{
         root.getChildren().clear();
         new Home(root);
    });

        menu2 = new Menu("Tools");

  menuItem2 = new MenuItem("Admin Panel");
   menuItem2.setOnAction(event ->{
        root.getChildren().clear();

     //   new APanel(root);
    });

    menu1.getItems().addAll(menuItem1, menuItem4, menuItem6, menuItem5);
    menu2.getItems().addAll(menuItem2, menuItem3);

    this.getMenus().add(menu1);
    this.getMenus().add(menu2);
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
casbaaa
  • 9
  • 1

1 Answers1

0

Right align menu in menubar in JavaFX

This should help you for your first problem. If not you could maybe replace the menuubar with a toolbar and do something like this:

How to right align a button in Java FX toolbar

For your second problem it depends on what the actual parent of the Gridpane is.
Using an AnchorPane as parent is the easiest solution here and then use it like this:

<AnchorPane fx:id="parent">
  <GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                    AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
    ...
  </GridPane>
</AnchorPane>
Amir Schnell
  • 611
  • 4
  • 11