I'm working on a javafx project that has a VBox inside a ScrollPane. The problem is that when the height of the vBox decreases, the scrollPane scrolls Up Automatically. How can i prevent that ? Knowing that it does not scrolls when the height increases!
Note: inside the vBox i have buttons which add/remove some TextFields which result in the increasing/decreasing of the VBox height.
I cannot show the whole code due to work regulations but here is where i define and add the VBox inside ScrollPane:
VBox mainVBox = new VBox();
mainVBox.setStyle("-fx-background-color: #0292b7");
mainVBox.setPrefWidth(400);
mainVBox.setSpacing(10);
mainVBox.setPadding(new Insets(3,5,3,5));
ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(mainVBox);
scrollPane.setPrefWidth(420);
scrollPane.setPrefHeight(600);
VBox.setVgrow(scrollPane,Priority.ALWAYS);