I'm trying to load an image inside a ScrollPane and make the image always fit to the width of the ScrollPane, even on window resize, so that you only have to scroll vertically. I'm using Scene Builder 8.5.0 and the Fit To Width property of the ScrollPane is set to true, but it doesn't work and the image still expands beyond the visible width of the ScrollPane. Preserve Ratio is also set to true. Here is the component hierarchy I used for this:
I also tried setting the fit to width property with code, but this doesn't work either
imgScrollPane.setFitToWidth(true);
Am I missing anything?

As you noticed your approach with the use of an
AnchorPanedoes not work as you expected.I agree with the comment from James_D and created two examples. The first example is the „quick-and-dirty way“ with a simple
Bindingbetween thefitWidthPropertyof theImageViewand thewidthPropertyof theScrollPane. The second example contains a little sample class customized for your needs which overrides thelayoutChildren()method.Example 1 (quick-and-dirty with
Binding):Example 2 (custom class with
layoutChildren()):