import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class JFXScrollPane extends Application {

    private static final double MY_WIDTH = 400;
    private static final double MY_HEIGHT = 800;

    private static final int N = 15;

    @Override
    public void start(Stage primaryStage) {

        ScrollPane scrollPane = new ScrollPane();

        Node[] verticalNodes = new Node[N];
        for (int i = 0; i < N; i++) {
            Node[] horizontalNodes = new Node[N];
            for (int j = 0; j < N; j++) {
                Rectangle rect = new Rectangle(0, 0, 100, 100);
                rect.setFill(Color.ORANGE);
                Text text = new Text(10, 25, String.format("Rect[%d,%d]", i, j));
                Group node = new Group(rect, text);
                horizontalNodes[j] = node;
            }
            VBox vBox = new VBox(5, horizontalNodes);
            verticalNodes[i] = vBox;
        }

        HBox hBox = new HBox(5, verticalNodes);
        scrollPane.setContent(hBox);

        primaryStage.setTitle("ScrollPane Sample");
        Scene scene = new Scene(scrollPane, MY_HEIGHT, MY_WIDTH);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
