在空JTextField中按下退格键时禁用蜂鸣声 [英] Disable beep when backspace is pressed in an empty JTextField
本文介绍了在空JTextField中按下退格键时禁用蜂鸣声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
初学者。当按下退格并且字段为空时,是否有人知道一种快速简便的方法让JTextField不发出蜂鸣声?我在网上看到了一些关于更改DefaultEditorKit的事情,但我没有能够理解。任何帮助将不胜感激。
Beginner here. Does anybody know a quick and easy way to get a JTextField to not beep when backspace is pressed and the field is empty? I've seen a couple things online about changing the DefaultEditorKit, but nothing I was able to make sense of. Any help would be greatly appreciated.
推荐答案
此代码适用于我。
Action beep = textArea.getActionMap().get(DefaultEditorKit.deletePrevCharAction);
beep.setEnabled(false);
这篇关于在空JTextField中按下退格键时禁用蜂鸣声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文