4

OK, I've been on this all day, and can't seem to make any sense of what is going on.

I have a TabPane, and within that, a Tab, the Tab's content is an AnchorPane, and within that, a SplitPane.

On the right side of the SplitPane, I have a ScrollPane, within that, a VBox. Into that VBox I put controls I've built in FXML, so they come one after another. That all works fine.

I've used AnchorPanes pretty much every to handle the resizing of my window, and it all works fine, except when I shrink the SplitPane containing the ScrollPane. When I enlarge my window, everything works fine, everything moves in accordance to it's anchor point, and it looks nice. When I come to shrink the window, though the ScrollPane essentially refuse to shrink, and my UI becomes all messed up because of it, the SplitPane seems to get pushed out of the window, because it can no longer shrink, because the ScrollPane won't.

This only happens on shrinking the window, if I start off with the window at a tiny size, the UI is fine, but if I then stretch out the window, and then return it to it's original size, the UI is all messed up. It's almost like once I stretch out the ScrollPane with anchor points, it'll refuse to get any smaller after that. There seems to be a bit of correlation with the content of the VBox in the ScrollPane, an empty VBox seems to allow the ScrollPane to shrink a bit more, but it's still problematic.

So basically, if I open up the Stage at 100x100 pixels, UI looks fine. If I then stretch out the window to 800x800, looks fine, if I think resize to 500x500, UI is messed up. So it's not like the UI won't fit, it's that once made bigger, it seems my ScrollPane refuses to shrink again.

I'm pretty much out of ideas at the moment, the rest of my app is also put together with AnchorPanes, and works fine.

Any thoughts, anything at all, much appreciated.

Garry

Garry
  • 623
  • 1
  • 7
  • 11
  • Experiencing the exact same behaviour. Did you figure this out? – stav Dec 26 '15 at 14:56
  • Kind of, I did a range of things, some of which worked better than others. First, when binding to the 'width' property, also set the 'min' and 'max' width properties, that seems to help. Also, put a ChangeListener onto the width property, then set the width of other things within a Platform.runLater, which seem to give things a chance to layout, and then set the width. I'm still not sure exactly why I'm getting that behaviour though. Try settings min/max/pref widths first, that worked in some areas very well. – Garry Dec 28 '15 at 00:25
  • 1
    For the sake of anyone reading, in the end a good way to get around this is to setManaged(false) on Nodes which are "decorative" and bind the width/height manually. It means the node will still stretch to fill it's area, but it will not prevent the area being make smaller. – Garry May 20 '17 at 12:02

1 Answers1

0

Setting the maximum and minimum width and height to use preferred size instead of computer size on Scenebuilder fixed this issue for me.1