Reputation: 3119
When I resize a window with split panes inside, my splitpanes are resized in what appears to be unpredictable ways. Sometimes the left pane is given more space, sometimes the right one. Sometimes the extra room is spread out, sometimes it is given entirely to one pane.
For example, maximizing and restoring the window will change the layout of the split panes -- before the process they'll be setup a certain way, afterwards they'll have completely different positions.
I would like instead for the splitpanes to always maintain the same ratio. So if before resize one is 30% of the width and the other is 70% of the width, i'd like for them to continue to be 30% / 70% afte the resize is complete.
Any suggestions on how to accomplish this?
Upvotes: 0
Views: 290
Reputation: 187
Glad you answered your own question. I advise to use Platform.runLater
instead of setResizableWithParent
to deal with the clever code you had issues with. See my answer there.
Upvotes: 1
Reputation: 3119
I was able to solve this problem by setting all of the top-level items in the UI to not resizable with parent:
SplitPane.setResizableWithParent( libraryPane, Boolean.FALSE );
SplitPane.setResizableWithParent( artSplitPane, Boolean.FALSE );
SplitPane.setResizableWithParent( currentListSplitPane, Boolean.FALSE );
SplitPane.setResizableWithParent( primarySplitPane, Boolean.FALSE );
SplitPane.setResizableWithParent( currentPlayingPane, Boolean.FALSE );
I don't know how it works or why, but I stumbled upon it and it does exactly what I want: Four Panes expand linearly while maintaining a basic ratio (library, primary split, current list, art) and one pane does not change size (current playing).
Here is a really badly annotated image:
My best guess is there is some clever code trying to intelligently resize content on window resize, and by setting ResizableWithParent
to false the clever code turns off and some basic code kicks in.
However it works, this worked perfectly for me, and I hope it helps others.
Upvotes: 0