如何区分应用程序退出和系统关闭 [英] Howto distinguish Application Quit from System Shutdown

查看:167
本文介绍了如何区分应用程序退出和系统关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • Mac OS X上的Java

在Swing GUI应用程序中,我想区分应用程序退出"和系统关闭".

In a Swing GUI app I want to distinguish Application Quit from System Shutdown.

在退出应用程序时,我想显示一个确认对话框,但是当用户选择系统关闭"时,我只是想退出该应用程序,因为系统中已经存在一个确认对话框.

On Application Quit I want to show a confirmation dialog, but when the user chooses System Shutdown I simply want to quit the app since there was already a confirmation dialog from the system.

这可能在其他平台上也很有趣.

This might be of interest on other platforms too.

德克

推荐答案

The OSXAdapter sample application shows how to (transparently) handle certain Apple events like quitting via ⌘-Q or from the dock menu.

这篇关于如何区分应用程序退出和系统关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆