Using key combination in Java

别说谁变了你拦得住时间么 提交于 2019-12-23 16:28:50

问题


I develop a Java application and need to enable entering special symbols by using a 'dead' key or key modifiers. For example, the user should be able to enter 'ñ' by pressing '`+n'.

I considered using key listeners but any event fired by a key is processed before the document is changed and I cannot alter that change. I also cannot change the key itself to allow direct entering the required symbol.

Please advise.


回答1:


I have found that KeyEvent.setKeyChar() method called from a key listener can replace the entered char. This allowed me to make char translation using ESC key as the prefix.



来源:https://stackoverflow.com/questions/32246698/using-key-combination-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!