85
Java JTextPane
JTextPane is a subclass of JEditorPane class. JTextPane is used for styled document with embedded images and components. It is text component that can be marked up with attributes that are represented graphically. JTextPane uses a DefaultStyledDocument as its default model.
Constructors
Constructor | Description |
---|---|
JTextPane() | It creates a new JTextPane. |
JtextPane(StyledDocument doc) | It creates a new JTextPane, with a specified document model. |
Useful Methods
Modifier and Type | Method | Description |
---|---|---|
Style | addStyle(String nm, Style parent) | It adds a new style into the logical style hierarchy. |
AttributeSet | getCharacterAttributes() | It fetches the character attributes in effect at the current location of the caret, or null. |
StyledDocument | getStyledDocument() | It fetches the model associated with the editor. |
void | setDocument(Document doc) | It associates the editor with a text document. |
void | setCharacterAttributes(AttributeSet attr, boolean replace) | It applies the given attributes to character content. |
void | removeStyle(String nm) | It removes a named non-null style previously added to the document. |
void | setEditorKit(EditorKit kit) | It sets the currently installed kit for handling content. |
void | setStyledDocument(StyledDocument doc) | It associates the editor with a text document. |
JTextPane Example
Output
Next TopicJava JRootPane