views:

19

answers:

0

So I am implementing DocumentListener in order to make a search text field that will perform searches as the user types. All of that is working correctly, but I recently also discovered a need to modify what the user has put into the text field. For example, I have a function that is removing any character not in the extended ascii set, and I am also replacing \n and \r with " " and changing and double+ spacing to just a single space.

Basically, I have no problem converting the string for search purposes, but when I go to update the string that is in the text field, I cannot update it since it appears AbstractDocument has put a writeLock in place when I entered the DocumentListener so as to avoid changes to the text field. I've tried trying to notify the thread in AbstractDocument that the listener is done, but this is disallowed as I am not the current thread's owner. Any ideas on how I can get the text field to update after an event in the DocumentListener?