如何在 JavaFX 中获取阶段的关闭事件?
在JavaFX中,如果用户单击关闭按钮(X)(最右边的交叉)一个阶段,我如何获取事件?
我希望我的应用程序在窗口关闭时打印调试消息。(System.out.println("Application Close by click to Close Button(X)")
)
@Override
public void start(Stage primaryStage) {
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
// Any Event Handler
//{
System.out.println("Application(primaryStage) Closed by click to Close Button(X)");
//}
}