title: JavaFX Gridpane search returns null nodes
body: <p>I want to implement my own custom dialogs in <code>JavaFX</code> from FXML files and I want to change the title and messages of the dialogs programmatically. My <code>.fxml</code> file has this structure for a typical dialog (I used an error one for this example):</p>
  
  <pre><code>&lt;StackPane prefHeight="140.0" prefWidth="290.0" style="-fx-background-color: #333333;" stylesheets="/style.css"
             xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
             fx:controller="apps.utils.Dialogs"&gt;
      &lt;children&gt;
          &lt;BorderPane&gt;
              &lt;center&gt;
                  &lt;GridPane&gt;
                      &lt;columnConstraints&gt;
                          &lt;ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/&gt;
                      &lt;/columnConstraints&gt;
                      &lt;rowConstraints&gt;
                          &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/&gt;
                          &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/&gt;
                          &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/&gt;
                      &lt;/rowConstraints&gt;
                      &lt;children&gt;
                          &lt;Label text="Error msg" textFill="LIGHTGRAY"/&gt;
                          &lt;Text fill="LIGHTGRAY" strokeType="OUTSIDE" strokeWidth="0.0"
                                text="My custom error message here"
                                wrappingWidth="250.0" GridPane.rowIndex="1"&gt;
                              &lt;GridPane.margin&gt;
                                  &lt;Insets top="10.0"/&gt;
                              &lt;/GridPane.margin&gt;
                          &lt;/Text&gt;
                          &lt;JFXButton onMouseClicked="#close"
                                     style="-fx-background-color: #da294f; -fx-border-radius: 5; -fx-background-radius: 5;"
                                     text="Retry" textFill="LIGHTGRAY" GridPane.halignment="CENTER" GridPane.rowIndex="2"
                                     GridPane.valignment="BASELINE"&gt;
                              &lt;GridPane.margin&gt;
                                  &lt;Insets top="20.0"/&gt;
                              &lt;/GridPane.margin&gt;
                          &lt;/JFXButton&gt;
                      &lt;/children&gt;
                  &lt;/GridPane&gt;
              &lt;/center&gt;
              &lt;StackPane.margin&gt;
                  &lt;Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/&gt;
              &lt;/StackPane.margin&gt;
          &lt;/BorderPane&gt;
      &lt;/children&gt;
  &lt;/StackPane&gt;
  </code></pre>
  
  <p>The method I use to show the dialog (in my controller class):</p>
  
  <pre><code>    public static void showDialog(StackPane rootPane, BorderPane rootBorderPane, URL dialogFile, String title, String message) throws IOException {
    rootBorderPane.setEffect(boxBlur);
          FXMLLoader loader = new FXMLLoader(dialogFile);
          loader.setClassLoader(cachingClassLoader);
          StackPane dialog = loader.load();
          ObservableList&lt;Node&gt; components = dialog.getChildren();
          BorderPane pane = (BorderPane) components.get(0);
          GridPane content = (GridPane) pane.getCenter();
          System.out.println("row: " + content.getRowCount() + " col:" + content.getColumnCount()); //prints Row 3, col 1
  
          Label dialogTitle = (Label) findNodeFromIndex(content, 0, 0);
          dialogTitle.setText(title);
          Text dialogMessage = (Text) findNodeFromIndex(content, 0, 1);
          dialogMessage.setText(message);
          //rest of the code to show dialog...
  }
  
  </code></pre>
  
  <p>Then I have a function to search through the Gridpane like this:</p>
  
  <pre><code>   private static Node findNodeFromIndex(GridPane gridPane, int col, int row) {
          for (int i = 0; i &lt; gridPane.getChildren().size(); i++) {
              Node node = gridPane.getChildren().get(i);
              if (GridPane.getRowIndex(node) == row &amp;&amp; GridPane.getColumnIndex(node) == col) {
                  return node;
              }
          }
          return null;
      }
  </code></pre>
  
  <p>Then I simply call <code>showDialog()</code> with the dialog type, and heading as well as custom heading/body text as my parameters.</p>
  
  <p>Now my issue is, I get a <code>NullPointerException</code> on the <code>setText()</code> methods. I can't figure out why that is. How could I fix this? </p>