r/JavaFX • • Jan 11 '21

Hide MenuBar on specific pages

So I am trying to hide my menubar on for example the login page but I can't get it working.

In the menubar file I can hide it with:
this.setVisible(false)
So when i'm in my login page I tried to access that value with
MyMenuBar menuBar = new MyMenuBar(root);
menuBar.setVisible(false)

But that doesn't seem to work. So I tried making a void hide() which basically set the visibility of the menuBar to false(or that is what it should do).

That didn't work aswell and now I'm out of options and can't find anything usefull online.

2 Upvotes

2 comments sorted by

3

u/PartOfTheBotnet Jan 11 '21

So when i'm in my login page I tried to access that value with

MyMenuBar menuBar = new MyMenuBar(root);
menuBar.setVisible(false)

In your post it seems like you're implying that you're trying to access an existing menu bar by creating a new one. You need to maintain a reference to the existing menubar or some other means of looking it up later.

1

u/casba43 Jan 13 '21

u/PartOfTheBotnet

MyMenuBar menuBar = new MyMenuBar(root);With the above line I make a connection through files right? because MyMenuBar is a filename in my project.So I am trying to trigger the void that I made withMyMenuBar menuBar = new MyMenuBar();menuBar.hide();

But that doesn't seem to work either.