According to the JavaDocs
If the owner window for the file dialog is set, input to all windows
in the dialog's owner chain is blocked while the file dialog is being
shown.
However, you are setting the owner window to a window that is not on the screen, so I think there is no "owner chain" in that case, and the file chooser is effectively not modal.
Why not just do
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
FileChooser fileChooser = new FileChooser();
fileChooser.showOpenDialog(stage);
}
});
so that you make the owner window of the file chooser the actual window?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…