I am facing an issue with ScrollPane, which is performs extremely slow on the relatively small amount of buttons as a content. I have 200+ ImageView inside and it works perfect, but after adding 200+ buttons for these images, scrolling became completely unusable. Even more, if I am trying to add just buttons, without images, they still make ScrollPane extremely slow:
public class TestApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
VBox container= new VBox();
ScrollPane root= new ScrollPane(container);
for (int i = 0; i < 400; i++) {
container.getChildren().add(new Button("Hello"));
}
stage.setScene(new Scene(root, 500, 250));
stage.show();
}
public static void main(String[] args) {
launch();
}
}
With 100 buttons is works, with 200 buttons it works slowly, with 400 buttons it is hard to say it works at all.
Is it the problem with my code or this ScrollPane so slow working with buttons?