Gridpane of Squares in JavaFX
<p>I'm newer to JavaFX and I'm attempting to make a checkerboard. I first want to start out by making a gridpane of squares that fill with random colors based on 
an array. I'm not sure why, but the squares aren't filling the rest of the grid. I'd also like to use constraints to set the grid height and width.</p>

<pre><code>int rowNum = 10;
int colNum = 10;
int gridHeight = 10;
int gridWidth = 10;

public void start(Stage primaryStage) {
    GridPane grid = new GridPane();

    //grid.getColumnConstraints().add(new ColumnConstraints(gridWidth));
    //grid.getRowConstraints().add(new RowConstraints(gridHeight));

    Random rand = new Random();
    Color[] colors = {Color.BLACK, Color.BLUE, Color.GREEN, Color.RED};

    int n = rand.nextInt(4)+1;
    for(int row = 0; row &lt; rowNum; row++){
           for(int col = 0; col &lt; colNum; col++){
               Rectangle rec = new Rectangle();
               rec.setWidth(2);
               rec.setHeight(2);
               rec.setFill(colors[n]);
               GridPane.setRowIndex(rec, row);
               GridPane.setColumnIndex(rec, col);
               grid.getChildren().addAll(rec);
           }
    }

    Scene scene = new Scene(grid, 350, 250);

    primaryStage.setTitle("Grid");
    primaryStage.setScene(scene);
    primaryStage.show();
}
</code></pre>

<p>Only one square appears on the top left.
Why is this the case?</p>