The workaround from @eckig or @jewelsea works pretty fine. But I would use something like this:
// Somewhere in code
Dialog<?> dialog = new Dialog<>();
Window window = dialog.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
I do not know any constrains of this use, but it worked for me.
And I recommend initialize window right after dialog initialization, like above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…