Handle Keyboard Keys ALT+F4 combination in Java
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am a windows user and i don't want to close my jframe when I press ALT+F4 , public void keyPressed(KeyEvent e) { if (KeyEvent.VK_SPACE, java.awt.event.InputEvent.CTRL_DOWN_MASK){ } } get the keystrokes and handle/stop closing or switching of the jframe so how can i handle this keypressed combination in java, please help.... 回答1: the previous will lock closing if indeed you press the key combination meaning there on even close X will not work. hence the following REVIEW: much better based on fast snail answer: public class