oldvipera
oldvipera

Reputation: 315

show hide panel in javafx using fxml

I have made the GUI of my javafx application in scenebuilder. I have correctly made the settings of placing the fxml and my application works perfect. Now I want to add action events to buttons and when a button is clicked, a panel should be shown and when other button is clicked, the other panel should be shown. Please help me. And remember that I am building my interface using scenebuilder i.e using fxml for my interface.

Thank you.

Upvotes: 3

Views: 13734

Answers (2)

dinith jayabodhi
dinith jayabodhi

Reputation: 591

you can use the following code and hide the panes you want to hide

(paneid).setVisible(false);

and appear the new code

(paneid).setVisible(True);

here the id is the what you put for "fx:id" in scenebuilder.

Upvotes: 2

ali sampson
ali sampson

Reputation: 467

What you can do is to write this code to hide the pane

(paneId).setVisible(false);
(paneId).setManaged(false);

and show it again by setting the parameters to true

(paneId).setVisible(true);
(paneId).setManaged(true);

Upvotes: 1

Related Questions