问题描述
我想在我的netbeans项目中禁用诸如alt
ctrl
alt + f4
ctrl + alt + dlt
之类的键盘热键,以便在我的应用程序处于打开状态时没有人可以打开任何东西
i want to disable keyboard hotkey such as alt
ctrl
alt + f4
ctrl + alt + dlt
in my netbeans project so that no one can open anything while my application is on
推荐答案
好吧,禁用密钥是一件困难的事情,但是我认为可以用另一种方法解决您的问题:
Well, disabling keys is a difficult thing, but i think you problem can be resolved another way:
yourFrameOrWindow.setAlwaysOnTop(true);
这将使您的应用程序始终显示在屏幕上,如果全屏显示,则可以解决您的问题,但这不会禁用ctrl + alt + del或其他尝试关闭应用程序的尝试.
This will make your application always on the screen, if its full screen, then your problem is solved, but this will not disable ctrl+alt+del, or other attempts to close your application.
对于某些组合键,我认为您可以在onKeyPress方法中将它们映射,然后将其清空,如下所示:
And for some combinations of keys, I think you can map them in a method onKeyPress an then let it empty, like this:
void onKeyPress(int keyCode){
if(keyCode == 43){
//do nothing
}
}
但是我认为有一个特定的按键组合监听器.
but i think have a specific listener for combinations of keys.
这篇关于如何在Java Swing中禁用键盘热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!