更新时间:2023-12-04 20:31:46
替换
stage.initModality(Modality.WINDOW_MODAL);
与
stage.initModality(Modality.APPLICATION_MODAL);
前者阻止如下:
定义一个模式窗口,该窗口阻止事件传递给它 整个所有者窗口层次结构.
Defines a modal window that block events from being delivered to its entire owner window hierarchy.
而后者:
定义一个模式窗口,该窗口阻止事件传递给任何事件 其他应用程序窗口.
Defines a modal window that blocks events from being delivered to any other application window.
来源: https://docs.oracle. com/javase/8/javafx/api/javafx/stage/Modality.html
Depending on why you want to achieve the aforementioned behaviour you might want to use JavaFX 8 Dialog available from JDK 8 Update 40