javax.swing
Class JTextPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JEditorPane
                                |
                                +--javax.swing.JTextPane
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Scrollable, Serializable
public class JTextPane
extends JEditorPane

A text component that can be marked up with attributes that are represented graphically. You can find how-to information and examples of using text panes in Using Text Components, a section in The Java Tutorial.

This component models paragraphs that are composed of runs of character level attributes. Each paragraph may have a logical style attached to it which contains the default attributes to use if not overridden by attributes set on the paragraph or character run. Components and images may be embedded in the flow of text.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JTextPane key assignments.

Newlines
For a discussion on how newlines are handled, see DefaultEditorKit.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

See Also:
StyledEditorKit

 

Nested Class Summary

 
Nested classes inherited from class javax.swing.JEditorPane
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Nested classes inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 

 

Field Summary

 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 

 

Constructor Summary

JTextPane()
    Creates a new JTextPane.
JTextPane(StyledDocument doc)
    Creates a new JTextPane, with a specified document model.
 

 

Method Summary

 Style addStyle(String nm, Style parent)
    Adds a new style into the logical style hierarchy.
protected  EditorKit createDefaultEditorKit()
    Creates the EditorKit to use by default.
 AttributeSet getCharacterAttributes()
    Fetches the character attributes in effect at the current location of the caret, or null.
 MutableAttributeSet getInputAttributes()
    Gets the input attributes for the pane.
 Style getLogicalStyle()
    Fetches the logical style assigned to the paragraph represented by the current position of the caret, or null.
 AttributeSet getParagraphAttributes()
    Fetches the current paragraph attributes in effect at the location of the caret, or null if none.
 Style getStyle(String nm)
    Fetches a named non-null style previously added.
 StyledDocument getStyledDocument()
    Fetches the model associated with the editor.
protected  StyledEditorKit getStyledEditorKit()
    Gets the editor kit.
 String getUIClassID()
    Returns the class ID for the UI.
 void insertComponent(Component c)
    Inserts a component into the document as a replacement for the currently selected content.
 void insertIcon(Icon g)
    Inserts an icon into the document as a replacement for the currently selected content.
protected  String paramString()
    Returns a string representation of this JTextPane.
 void removeStyle(String nm)
    Removes a named non-null style previously added to the document.
 void replaceSelection(String content)
    Replaces the currently selected content with new content represented by the given string.
 void setCharacterAttributes(AttributeSet attr, boolean replace)
    Applies the given attributes to character content.
 void setDocument(Document doc)
    Associates the editor with a text document.
 void setEditorKit(EditorKit kit)
    Sets the currently installed kit for handling content.
 void setLogicalStyle(Style s)
    Sets the logical style to use for the paragraph at the current caret position.
 void setParagraphAttributes(AttributeSet attr, boolean replace)
    Applies the given attributes to paragraphs.
 void setStyledDocument(StyledDocument doc)
    Associates the editor with a text document.
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener,