Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of

The point.

A JTextPane is used...

to edit a DefaultStyledDocument.


Create a style,...

containing attributes...

and apply it to the text to be inserted.

Create another style based on the previous one, that should inherit its attributes.

Override an attribute...

and add one.

Use this style in the actionPerformed method.

Another style...

containing paragraph attributes instead of character attributes.

Apply it later on.


It's easy to save a document.

Not so easy to print the textpane's content.

These last two methods are only in the example to show how to do it, they're not called.




Don't expect all features to work, especially in older versions.


JTextArea and JTextField have an associated Document, too. Without style-support, however.