我尝试了使用
addWindowListener
并实现windowClosing
,它可以在按下关闭按钮时运行。但是当我使用Cmd+Q
关闭时,windowClosing
没有被调用。我该怎么解决呢?我需要通过键盘监听器检测Mac上的Cmd+Q
,Windows上的Alt + F4
吗?是否有通用的监听器可用于关闭窗口,无论是通过关闭按钮还是键盘,甚至是Ctrl+Alt+Delete
或Cmd+Option+Esc
来强制关闭?谢谢。