You can use the snap to adjust this position of a special object based on the position of the scroll bar, see the following code:
public class FancyScrollPane extends Application { @Override public void start(Stage primaryStage) { ScrollPane scrollPane = new ScrollPane(); Pane content = new Pane(); scrollPane.setContent(content);
source share