如何通过右键单击->关闭窗口检测窗口关闭?
当有人通过右键单击应用程序并执行“关闭窗口”从任务栏(而不是直接从应用程序本身)关闭基于桌面的 Java/JavaFx 应用程序时,是否会触发一个事件?
目前,如果我从任务栏关闭窗口,应用程序窗口将关闭,但进程不会被终止并继续在后台运行。我想完全关闭应用程序,以便应用程序中的嵌入式 Derby DB 断开连接。
我尝试过Stage的setOnHiding()
、setOnCloseRequest()
和其他类似的方法,但没有效果。
感谢您的帮助!
Is there an event that gets fired when somebody closes a desktop-based Java/JavaFx application from the task bar (and not directly from the application itself) by right clicking on the application and executing Close Window?
Currently, if I close the window from the taskbar, the application window gets closed but the process does not get killed and keeps running in the background. I want to shut down the application completely, so that the Embedded Derby DB within the application gets disconnected.
I have tried the Stage's setOnHiding()
, setOnCloseRequest()
and other similar methods, but to no avail.
Thanks for all your help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用ShutdownHook来释放应用程序资源。
You can try to use ShutdownHook to free application resources.