title: Custom JavaFX Dialog
body: <p>I want to create a custom JavaFX dialog. So far I've create something like that:</p>
  
  <pre><code>public class LoginDialog extends Dialog {
  
      public LoginDialog(Data data) {
          try {
              FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/LoginDialog.fxml"));
              Parent root = loader.load();
              LoginDialogController controller = loader.&lt;LoginDialogController&gt;getController();
              controller.setModel(new LoginModel(data));
              getDialogPane().setContent(root);
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>But - at first I'm not convinced that this is the right way to do this. </p>
  
  <p>Secondly - I wish to use a Button declared in LoginDialog.fxml file to close this LoginDialog, after showAndWait() call. Is it possible? How can I set the return value?</p>