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
I did it by using an AnimationTimer. I had to wait for 100000000 nanoseconds to be sure that the ScrollPane had reacted to the expanded Titlepane.
public void scrollNodeInTopScrollPane(Node n, ScrollPane s) {
final Node node = n;
final ScrollPane clientTopScrollPane = s;
AnimationTimer timer = new AnimationTimer() {
long lng = 0;
@Override
public void handle(long l) {
if (lng == 0) {
lng = l;
}
if (l > lng + 100000000) {
if (node.getLocalToSceneTransform().getTy() > 20) {
clientTopScrollPane.setVvalue(clientTopScrollPane.getVvalue() + 0.05);
if (clientTopScrollPane.getVvalue() == 1) {
this.stop();
}
} else {
this.stop();
}
}
}
};
timer.start();
}