Question

Okay, I want to override JTextArea's Document's remove method, I can't figure out what class to extend. I can't extend Document cause it's a interface, and that also means it must not be the document that JTextArea creates. So how exactly can I easily override my JTextArea's document's remove method?

Was it helpful?

Solution

The default Document of a JTextArea is PlainDocument, as mentioned in createDefaultModel(). Here is a simple example of overriding insertString() in PlainDocument.

OTHER TIPS

Try to use DocumentFilter instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top