title: Opening new window from an external Thread in Javafx
body: <p>I want to open a new window (Stage) in javafx from an external Thread (not from the principal Thread). my code bellow is not working, please help me.</p>
  
  <p>This is my java code :        </p>
  
  <pre><code>public void login(ActionEvent event)
  {       
      Task task = new javafx.concurrent.Task&lt;Void&gt;()
      {
              @Override
              protected Void call() throws Exception 
              {
                  loader.setVisible(true);
                  if(Compte.login(username.getText(), password.getText()))
                  {
                      Parent root = FXMLLoader.load(getClass().getResource("/views/PrincipalFram.fxml"));
                      Scene scene = new Scene(root);
                      Stage stage = new Stage();
                      stage.setScene(scene);
                      stage.setTitle("My Title");
                      stage.show();
                  }
                  else
                  {
                      //TODO 
                  }
                  return null;
              }
  
              @Override
              protected void succeeded() 
              {
                  loader.setVisible(false);
              }
  
              @Override
              protected void failed() 
              {
                  loader.setVisible(false);
              }
      };
      Thread thread = new Thread(task);
      thread.setDaemon(true);
      thread.start();
  }
  </code></pre>