I suspect this is going to end up as a feature request, but does anyone know if there is an existing way to have a ScrollPane stretch its content if the available space is greater than the preferred size of the content, but also
not shrink the content if the scrollpane is smaller than the preferred size of the content?
If we have this simple example:
public void start(Stage stage) throws Exception
{
BorderPane contentPane = new BorderPane();
contentPane.setPrefSize(400, 300);
contentPane.setStyle("-fx-background-color: blue");
ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(contentPane);
Scene scene = new Scene(scrollPane, 800, 600);
stage.setScene(scene);
stage.show();
}
When the window is big, our content pane is left at its preferred size with white space around it and no scroll bars showing. When the window is small our contentPane is still at its preferred size with scrollbars on it and no white space. Much as we'd expect.
If we add this line of code:
scrollPane.setFitToWidth(true);
Then when the window is big then our contentPane is stretched nicely to fill the available space. When the window is small, the scroll bars don't kick-in (effectively scrolling is turned off) and the contentPane is shrunk to fit the available space.
What I'd rather have is when the window is small we get scrolling, when the window is big, we get stretching. Possible?
Cheers,
zonski