title: Javafx create rectangles in a loop
body: <p>I am learning Javafx and am having trouble getting my for loop to create a new rectangle on each iteration. When I run the program it creates one rectangle at the top left position and that is it. My goal is to create a grid of rectangles based on the amount of columns, rows, pixels wide, and pixels tall specified. Everything is tested to work besides the creation of rectangles.</p>
  
  <pre><code>for(int i = 0; i &lt; columns; ++i)
      {//Iterate through columns
          for(int j = 0; j &lt; rows; ++j)
          {//Iterate through rows
              Color choice = chooseColor(rectColors);
              //Method that chooses a color
  
              rect = new Rectangle(horizontal*j, vertical*i, horizontal, vertical);
              //Create a new rectangle(PosY,PosX,width,height)
  
              rect.setStroke(choice);
              //Give rectangles an outline so I can see rectangles
  
              root.getChildren().add(rect);
              //Add Rectangle to board
  
          }
      }
  </code></pre>
  
  <p>I am trying to figure out why the rectangles aren't being created. Any help would be greatly appreciated.</p>