Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX auto-scroll down scrollpane

Tags:

java

javafx-2

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 ScrollPane) and when I expand it I would like the ScrollPane to scroll down so I can see the entire content of the TitledPane.

like image 803
nailujed Avatar asked Nov 28 '22 08:11

nailujed


2 Answers

You can bind the ScrollPane vvalue property with the heightProperty of the inner container. For example, if you have a VBox in your ScrollPane:

scrollPane.vvalueProperty().bind(vBox.heightProperty());
like image 56
Jeankowkow Avatar answered Dec 04 '22 17:12

Jeankowkow


You can achieve that behaviour With combination of titledPane.localToScene() and scrollPane.setVvalue()

The first is to get titledPane's coordinates while the second is to set scrollPane's vertical bar position. Note that it's range is between 0 - 1.

like image 25
amru Avatar answered Dec 04 '22 15:12

amru