Is there any way of auto scroll down a ScrollPane control when it content\'s height increases ? For example, I have a TitledPane on the bottom of the screen (inside a Scroll
You have to tell scrollpane where is the current coordinates before pass a value to the vertical or horizontal bar.
This code works pretty fine for me:
// the owner's node of your scrollPane;
titledPane.layout();
// the maxValue for scrollPane bar ( 1.0 it's the default value )
scrollPane.setVvalue( 1.0d );
You have to code this where your scrollpane grows. For example, if you add nodes to the scrollpane inner node, them, add a listener to it's children list.
If the inner node of scrollpane change it's height, add a listener to the heightProperty.
For example, the inner node of your scrollPane it's an AnchorPane and you add nodes to this pane, so do like this:
anchorPane.getChildren().addListener(
( ListChangeListener.Change extends Node> c ) -> {
titledPane.layout();
scrollPane.setVvalue( 1.0d );
}
);
If it's the height which grows...
heightProperty().addListener(
(observable, oldValue, newValue) -> {
titledPane.layout();
scrollPane.setVvalue( 1.0d );
}
);
That's it!