如何使用Esc键退出我的应用程序?
问题描述:
我试试这段代码但它不起作用?请你帮助我好吗?谢谢..
Hi, I try this code but it doesn't work ? Could you please help me? Thanks..
private void formKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.exit(0);
}
}
答
我会谷歌那样做。例如,按下某个键时,这个java - 关闭窗口 - Stack Overflow [ ^ ]是快速搜索的第一个结果之一。
I would Google for that. For instance, this "java - Close window on pressing of certain key - Stack Overflow"[^] was one of the first results of a quick search.