gluongluon-mobile

Opening a Dialog from within the postInit() method


I am trying to open a Dialog from within the MobileApplication.postInit() method, like this:

public void postInit(Scene scene) {
   new CustomDialog().showAndWait();
}

where CustomDialog extends Dialog. However, when I run this, the application starts up but never displays the home view, or the dialog. The program runs, and Netbeans sits there waiting for it to finish, but it never does, and nothing ever comes up on the screen.

My application needs to open a password-encrypted data file before it can show the main view, so what's the correct way to use a dialog to prompt for a password when the application first starts?


Solution

  • Circling back to answer my own question: if you want a dialog to come up when your application starts, program that logic into the main stage that is launched when the application starts, and then once the password is verified (or whatever else the start-up dialog does is complete), then create a new stage with the real main application interface.