title: JavaFX - How to get FXML Controller?
body: <p>I have the following code:</p>
  
  <pre><code>Parent parent = FXMLLoader.load(Main.class.getResource("JanelaPrincipal.fxml"));
  </code></pre>
  
  <p>in the fxml file there is a reference to the controller class. How can I get the controller object?</p>
  
  <hr>
  
  <p>fxml:</p>
  
  <pre><code>&lt;AnchorPane id="AnchorPane" fx:id="root" 
      prefHeight="768.0" prefWidth="1024.0" xmlns:fx="http://javafx.com/fxml/1" 
      xmlns="http://javafx.com/javafx/2.2" 
      fx:controller="br.meuspila.javafx.JanelaPrincipalController"&gt;
      ...
  </code></pre>