You have to change your key listener from Released to Pressed. Reason is on release it check so your characters go out of range. Hope this help.
public void keyPressed(KeyEvent key)
Majestics
Practically a Master Poster
696 posts since Jul 2007
Reputation Points: 209
Solved Threads: 66
Skill Endorsements: 5
Question Answered as of 8 Months Ago by
Majestics
and
jalpesh_007 not never to use KeyListener for JTextComponents, wrong way, have look at DocumentFilter for special Chars to use Pattern
mKorbel
Nearly a Posting Virtuoso
1,228 posts since Feb 2011
Reputation Points: 482
Solved Threads: 244
Skill Endorsements: 14
mKorbel's advice is good. Unlike KeyListener, a DocumentListener will correctly deal with copy/paste and programatic changes to the text. as well as anything the user types
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,477
Skill Endorsements: 33