This would be slightly more efficient (than using setText()) because you are just appending text directly to the Document and would more resemble a JTextArea.append(...).
It would only result in a single DocumentEvent - insertUpdate().
You can also access the Document directly and do the insert:
If you text field is not editable, you could use:
If it is editable you might use:
This would be slightly more efficient (than using setText()) because you are just appending text directly to the Document and would more resemble a JTextArea.append(...).
It would only result in a single DocumentEvent - insertUpdate().
You can also access the Document directly and do the insert:
but I find this more work because you also have to catch the BadLocationException.
Simple example, that also demonstrate the use of Key Bindings:
I think you'll find
setText
is the answer. Just combine the current value with the new value: