Swout应用程序的OnExit事件? [英] OnExit Event For a Swing Application?
本文介绍了Swout应用程序的OnExit事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个简单的应用程序来使用Swing来管理业务的运营部分,但我需要在应用程序退出时执行此操作:
I'm developing a simple application to manage the operational part of a business using Swing, but I need that when the application exits, it performs this:
updateZonas();
db.close();
但我怎么能这样做?
推荐答案
Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
updateZonas();
db.close();
}
});
这适用于任何Java应用程序(Swing / AWT / Console)
This works for any Java application(Swing/AWT/Console)
这篇关于Swout应用程序的OnExit事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文