Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX - Make ScrollPane scroll automatically

I have a Label inside a ScrollPane. I am updating the label in a loop (In another thread). How can I update the ScrollPane so it scrolls down (not sideways, this will be done manually) if the user doesnt hold it at a position? Is there a setter for it?

like image 753
user3029101 Avatar asked Dec 02 '13 16:12

user3029101


2 Answers

To set the ScrollPane to the bottom automatically set the vvalue of the ScrollPane element, like this:

@FXML private ScrollPane scroll; //this must match the fx:id of the ScrollPane element
scroll.setVvalue(1.0);           //1.0 means 100% at the bottom
like image 119
Math Avatar answered Sep 18 '22 21:09

Math


This works in my code:

scrollPane.vvalueProperty().bind(mainGrid.heightProperty());

in my case scrollPane contains mainGrid

like image 27
brack11 Avatar answered Sep 19 '22 21:09

brack11