title: Javafx FXMLLoader.getController() method returns null
body: <p>When creating the display in my main loop, the loader for an AnchorPane FXML returns null when getController() is called.</p>
  
  <pre><code>    //instantiates the FXMLLoader class by calling default constructor
          //creates an FXMLLoader called loader
          FXMLLoader loader = new FXMLLoader();
  
          //finds the location of the FXML file to load
          loader.setLocation(mainApp.class.getResource("/wang/garage/view/ItemOverview.fxml"));
  
          //sets the AnchorPane in the FXML file to itemOverview
          //so that the AnchorPane is set to the display of the app
          AnchorPane itemOverview = (AnchorPane) loader.load();
          rootLayout.setCenter(itemOverview);
  
          //finds the controller of the itemOverview and
          //sets it to controller variable
          //then provides a reference of mainApp to controller to connect the two
          ItemOverviewController controller = loader.getController();//returns null
          controller.setMainApp(this);
  </code></pre>
  
  <p>I did not specify the controller in the FXML document. Is this necessary if I am using loader.load()? If so, how should I specify the controller in the FXML document?</p>