title: How to get stage from controller during initialization?
body: <p>I want to handle stage events (i.e. hiding) from my controller class. So all I have to do is to add a listener like this:</p>
  <pre><code>((Stage) myPane.getScene().getWindow()).setOn*whatIwant*(...);
  </code></pre>
  <p>But the problem is that initialization starts right after this code:</p>
  <pre><code>Parent root = FXMLLoader.load(getClass().getResource(&quot;MyGui.fxml&quot;));
  </code></pre>
  <p>And before this code:</p>
  <pre><code>Scene scene = new Scene(root);
  stage.setScene(scene);
  </code></pre>
  <p>Thus <code>getScene</code> returns null.</p>
  <p>The only workaround I found by myself is to add a listener to <code>myPane.sceneProperty</code>, and when it becomes not null I get scene, add to it's <code>windowProperty</code> my listener handling which I finally retrieve stage. And it all ends with setting desired listeners to stage events.</p>
  <p>I think there are too many listeners.</p>
  <p>Is it the only way to solve my problem?</p>