title: Javafx - Can application class be the controller class
body: <p>I'm currently teaching myself JavaFX, and I've taken a simple example program that's hardcoded the view and am turning it into one that uses FXML (mostly so I can use SceneBuilder for building UIs). Rather than writing a separate controller class, I'm using the application class (so there's 1 Java file and 1 FXML file). I'm not using an <code>initialize()</code> method as it's a linear flow (display the UI, populate the fields, wait for input). The view pops up, but then the app errors out as none of the controls are mapped to the appropriate variables (so for <code>@FXML TableView&lt;...&gt; table</code>, <code>table</code> is <code>null</code>).</p>
  
  <p>However, I put in an <code>initialize()</code> method for debugging, the controls are injected while in <code>initialize()</code>, and then return to null when <code>initialize()</code> exits.</p>
  
  <p>So the question is, does JavaFX instantiate a new instance of the application class as a separate controller class? This would explain why the variable are going out of scope. Or is it something else (e.g. the controls are injected only when being called back from JavaFX actions)?</p>