swing - How to substitute a pressed char in Java -


when user presses "dot" key on keypad in in jtextfield i'd transparently substitute comma. tried this:

jtextfield.addkeylistener(new keyadapter() {    @override    public void keytyped(keyevent event) {        if (event.getkeycode() == keyevent.vk_decimal) {          event.setkeychar(',');        }      } }); 

but doesn't work.

instead of trying associate new key happened key event (this impossible think), should try directly manipulating text of related jtextfield instance via call yourtextfield.settext(","); in if statement of code snippet above.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c++ - libcurl curl_easy_setopt "Unknown error" -

vb6 - PostgreSQL ODBC Connection SSPI Authentication Failure -