I am using a JTextField, wherein I am filtering input coming in via REGEXs and notifying the user (background color changes) and then pushing the updates out over a socket (character by character, not a 'Hit enter when you're done' kind of behavior, by spec)
The issue is, since there's no guaranteed order of DocumentListener notification, I cannot put both the transmission of the update and the validation of the update on the same kind of listener. Is there any guaranteed order of notification amongst different kinds of Listeners (KeyListener vs DocumentListener vs ... ) with a JTextField?
I can find no helpful documentation about between different kinds of Listeners, only (it seems) within a single kind of Listener (such as a DocumentListener)
Thanks!
EDIT 1 Validation - REGEX validation does not permit me to disallow any text coming in since additional characters may make an 'invalid' string 'valid'.
Separation of Behavior - By design, I cannot merge the two behaviors into one listener, they are being set up at different times in the code flow and that cannot be changed. It's a protocol design issue that's not up for debate. I can't really go into more useful detail without just explaining the whole thing. The salient point is they are just separated into two listeners. I need to make the transmission step happen after the validation step, so I need to know if there is a CONCRETE definition of Listener KIND notification. By Kind I mean KeyListener vs DocumentListener vs UndoableEditListener. I know within each kind of listener no order is guaranteed.
However, is it guaranteed that DocumentListeners are all notified before UndoableEditListeners or vice versa? Or are all different kinds of listeners just notified in no particular order whatsoever.
EDIT 2
Sorry, it seems as we are getting lost in the weeds hardcore.
At this moment, all I am trying to figure out is:
Is there a Java-language guarantee as to the order in which different classes of Listeners (such as: Key, Document, UndoableEdit) on a JTextField are notified?