title: Pass object from main class to JavaFX Application
body: <p>I have simple main class. 
  There i try pass <code>user</code> to <code>WindowLogin</code> : </p>
  
  <pre><code>package client;
  
  
  public class Client{
  
      public User user;
  
      public static void main(String[] args) {
  
          try {
              Client client = new Client();
              client.run(args);
          } catch (Exception e) {
              System.out.println("[ERR] Fatal error");
          }
  
      }
  
      public void run(String[] args)
      {
  
          user = new User();
  
          WindowLogin windowLogin = new WindowLogin();
          windowLogin.user = user;
          windowLogin.show();
  
      }
  
  }
  </code></pre>
  
  <p>Window main class. There i try call <code>test()</code> function of <code>user</code> (in real, i need it pass to <code>WindowMainController</code>):</p>
  
  <pre><code>package client;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  import javafx.scene.Parent;
  
  import java.io.IOException;
  
  public class WindowLogin extends Application{
  
      private Stage stage;
      public User user;
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          stage = new Stage();
          try {
              FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("views/WindowLogin.fxml"));
  
              WindowLoginController controller =
                      fxmlLoader.&lt;WindowLoginController&gt;getController();
  
              user.test();
  
              Parent root = fxmlLoader.load();
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
      public void show(){
          launch();
      }
      public void hide() { stage.hide(); }
  
  }
  </code></pre>
  
  <p>When i try to run it all:</p>
  
  <p><code>Exception in Application start method</code></p>
  
  <p>Of course (maybe :) ) it because of <code>user</code> in windowLogin is <code>null</code>.</p>
  
  <p>What i doing wrong? How pass <code>user</code> to <code>windowLogin</code>? (i wont use Singletone)</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I need use <code>user</code> in start() method, as i said before - i need pass <code>user</code> to <code>WindowMainController</code></p>