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
Post a Comment