ScrollPane needs GrowToFitWidth?

David Grieve david.grieve at
Fri Jan 31 11:47:14 PST 2014

I encourage you to take a hack at ScrollPaneSkin. In particular the method computeScrollNodeSize. I suspect the change would be pretty much localized to this method. 

On Jan 31, 2014, at 2:02 PM, Jeff Martin <jeff at> wrote:

> ScrollPane has the feature for content that needs to track the viewportBounds size, FitToWidth/FitToHeight, which is nice for things like text areas that wrap text. Conceptually, it seems like FitToWidth is basically binding Content.PrefWidth to ViewportBounds.Width.
> But it seems more often I really want to bind Content.MinWidth/MinHeight to ViewportBounds.Width/Height. This is common for things like text areas that don't wrap text or most text area height (and much more). So I end up doing a bit of this:
>    // Add content to ScrollPane and make sure it is at least as big as ViewportBounds
>    final Region content = myContent;
>    ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(content);
>    scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
>        public void changed(ObservableValue<? extends Bounds> arg0, Bounds oldBounds, Bounds newBounds)
>        { content.setMinWidth(newBounds.getWidth()); content.setMinHeight(newBounds.getHeight()); }});
> To me, this makes it seem like the ScrollPane is only there when it's needed (otherwise, it's like an invisible Parent Pane). This seems ideal for a default ScrollPane.
> Obviously, this isn't a lot of code, but it's non-obvious, and from googling, it looks like people stumble over FitToWidth first. It seems to me that a setGrowToFitWidth/setGrowToFitHeight would be at least as useful. Unless I missed something. :-)
> Jeff Martin
> 214.513.1636

More information about the openjfx-dev mailing list