I am writing a user control based on JTextField. My JTextField uses my own Document class, derived from PlainDocument, so that I can handle all user input in the redefined methods of insertString(...) and remove(...) .
Here is the problem. After processing user input, sometimes I want to move the cursor to another position. What is the best way to do this?
By default, the document places a caret next to the last entry. So I tried to put the char at my target position and immediately delete it. For some reason, it does not work in the remove() method ... and the code does not look very good :)
Thanks for and suggestions.
source share