William
William

Reputation: 8808

Override JTextArea.getDocument.remove()?

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?

Upvotes: 3

Views: 529

Answers (2)

StanislavL
StanislavL

Reputation: 57421

Try to use DocumentFilter instead.

Upvotes: 0

trashgod
trashgod

Reputation: 205875

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

Upvotes: 2

Related Questions