Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 8, how to hide a pane in Splitpane?

I have a splitpane created from FXML that consists of Three panes left to right. I want to be able to hide the rightmost pane but I can't find anything to hide it. If I turn of the visibility it hides the pane content. What I want is to temporarily hide it, so the pane is removed visually.

As a temporary workaround I move the divider to 100%, but this leaves the divider visible. Another side-effect is that if I resize the main window the divider doesn't stay at the rightmost position.

Any tips on hiding one pane in splitpane?

Or any tips on the best way to achieve this without splitpane(rightmost pane needs to be resizable when not hidden). General pointers to techniques/containers would be appreciated since I'm new to Java/JavaFX but not to programming :)


like image 308
Backtomusic Avatar asked Dec 07 '14 22:12

Backtomusic


1 Answers

Seems I've found it, even thought it's not a plain hide/show deal. My splitpane is named "mainSplitPane", and the one I want to hide/show is the third. Upon initialization of the controller I retrieve the third pane and store it in "componentsPane".

Declared in controllerclass:

Node componentsPane;

Called in initialize method of the controllerclass:

componentsPane=mainSplitPane.getItems().get(2); 

Code to hide:

mainSplitPane.getItems().remove(componentsPane); 

And code to show:

mainSplitPane.getItems().add(2, componentsPane); 
mainSplitPane.setDividerPosition(1, 0.8); 

A side effect is that I have to set dividerposition since it's removed.

like image 122
Backtomusic Avatar answered Sep 23 '22 14:09

Backtomusic