Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

KeyTyped character not correct with a barcode reader

stevehelFeb 8 2013 — edited Feb 9 2013
Hi,

I have done a simple frame with a JTextField for which I added a KeyListener, and something strange happens.

When I type with a keyboard no problem characters are rightly inserted in the text field.

But when I read a barcode with a barcode reader (Symbol), sometimes (not always) some characters are replaced by others.

For Example I read this 000010 but the text in the text field is 000ê10 (not always the same character replaced...)

I have added some logs for keyPressed, keyRealesed and keyTyped methods : For the wrong chraracter, keyPressed and keyReleased are correct, but the keyTyped method return a char that is not the one corresponding to the character types...

In this exemple below I have scanned a barcode, for the character '6' I got a ¨... I have added the event.paramString() in the log...
Key pressed : Alt - KEY_PRESSED,keyCode=18,keyText=Alt,keyChar=Undefined keyChar,modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_LEFT,rawCode=18,primaryLevelUnicode=0,scancode=56
Key pressed : NumPad-0 - KEY_PRESSED,keyCode=96,keyText=NumPad-0,keyChar='0',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=96,primaryLevelUnicode=48,scancode=82
Key released : NumPad-0 - KEY_RELEASED,keyCode=96,keyText=NumPad-0,keyChar='0',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=96,primaryLevelUnicode=48,scancode=82
Key pressed : NumPad-5 - KEY_PRESSED,keyCode=101,keyText=NumPad-5,keyChar='5',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=101,primaryLevelUnicode=53,scancode=76
Key released : NumPad-5 - KEY_RELEASED,keyCode=101,keyText=NumPad-5,keyChar='5',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=101,primaryLevelUnicode=53,scancode=76
Key pressed : NumPad-4 - KEY_PRESSED,keyCode=100,keyText=NumPad-4,keyChar='4',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=100,primaryLevelUnicode=52,scancode=75
Key released : NumPad-4 - KEY_RELEASED,keyCode=100,keyText=NumPad-4,keyChar='4',modifiers=Alt,extModifiers=Alt,keyLocation=KEY_LOCATION_NUMPAD,rawCode=100,primaryLevelUnicode=52,scancode=75
Key released : Alt - KEY_RELEASED,keyCode=18,keyText=Alt,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=18,primaryLevelUnicode=0,scancode=56
Key typed : Unknown keyCode: 0xa8 - KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='¨',keyLocation=KEY_LOCATION_UNKNOWN,rawCode=0,primaryLevelUnicode=0,scancode=0
Any idea of what could cause this strange comportment ?

Thanks for your help.

Steve
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 9 2013
Added on Feb 8 2013
1 comment
798 views