Hello.
My question today is, hopefully, a simple one: is there an easy way to have a JTextField (or JTextArea or any simillar component) that only allows to input text but not modify in any way what's already been entered?
The behaviour I'd like to have is that once the user has entered a character, he can neither delete it, nor cut it, nor reposition the caret (therefore making it impossible to enter new text before the already typed text; all new text should be appended to the end of the previous text).
So far, the only solution I see involves writing a class that implements KeyListener (or extends KeyAdapter) and another that implements CaretListener, and register them as the KeyListener and CaretListener of the JTextField. The KeyListener would ignore KeyEvents that match the backspace, delete, and arrow keys, and the CaretListener would reposition the caret if it's moved anywhere except the end of the text. Would that accomplish what I want? Is there a better or easier way to do it?
Thanks in advance.

