How to make owner of a JavaFX dialog is another dialog?

Viewed 669

I have a LoginDialog. RecoverPasswordDialog will be opened from LoginDialog. I am finding a way to make LoginDialog is the owner of RecoverPasswordDialog.

Here is my code:

public class LoginDialog extends Dialog<String> {

    @FXML
    public void handleForgotPasswordClick() {

         RecoverPasswordDialog dlg = new RecoverPasswordDialog();

         dlg.initOwner(LoginDialog.this); // ERROR because LoginDialog is not Window

         dlg.show();
    }
}

I know I can do like this

dlg.initOwner(primaryStage);
OR
dlg.initOwner(LoginDialog.this.getOwner());

But if I do that, LoginDialog is not the parent of the RecoverPasswordDialog.

Any ideas? Thanks!

1 Answers
Related