KeyEvent
s are low-level events that are not appropriate here [that sounds familiar].
How does the JTextField
system know that a character has been typed? Through a key typed event (IIRC, done through the PL&F). Does the event get dispatched to the system listener before your listener? It might or might not do.
In this case, you probably want to go to the Document
and add a higher-level listener. With Swing it's a good idea to go for the model early - the 'J' class interfaces are incoherent. If you are intercepting input data, then you probably want a custom model (or in the case of Document
a DocumentFilter
).