JTextPane (Java 2 Platform SE 5.0) (original) (raw)

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 inUsing 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 a discussion on how newlines are handled, seeDefaultEditorKit.

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/interfaces inherited from class javax.swing.JEditorPane
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
Fields inherited from class javax.swing.JEditorPane
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
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](../../javax/swing/JTextPane.html#addStyle%28java.lang.String, javax.swing.text.Style%29)(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](../../javax/swing/JTextPane.html#setCharacterAttributes%28javax.swing.text.AttributeSet, boolean%29)(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](../../javax/swing/JTextPane.html#setParagraphAttributes%28javax.swing.text.AttributeSet, boolean%29)(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](../../javax/swing/JEditorPane.html#read%28java.io.InputStream, java.lang.Object%29), [registerEditorKitForContentType](../../javax/swing/JEditorPane.html#registerEditorKitForContentType%28java.lang.String, java.lang.String%29), [registerEditorKitForContentType](../../javax/swing/JEditorPane.html#registerEditorKitForContentType%28java.lang.String, java.lang.String, java.lang.ClassLoader%29), removeHyperlinkListener, scrollToReference, setContentType, [setEditorKitForContentType](../../javax/swing/JEditorPane.html#setEditorKitForContentType%28java.lang.String, javax.swing.text.EditorKit%29), setPage, setPage, setText
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, [addKeymap](../../javax/swing/text/JTextComponent.html#addKeymap%28java.lang.String, javax.swing.text.Keymap%29), copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, [getScrollableBlockIncrement](../../javax/swing/text/JTextComponent.html#getScrollableBlockIncrement%28java.awt.Rectangle, int, int%29), [getScrollableUnitIncrement](../../javax/swing/text/JTextComponent.html#getScrollableUnitIncrement%28java.awt.Rectangle, int, int%29), getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, [getText](../../javax/swing/text/JTextComponent.html#getText%28int, int%29), getToolTipText, getUI, isEditable, [loadKeymap](../../javax/swing/text/JTextComponent.html#loadKeymap%28javax.swing.text.Keymap, javax.swing.text.JTextComponent.KeyBinding[], javax.swing.Action[]%29), modelToView, moveCaretPosition, paste, processInputMethodEvent, [read](../../javax/swing/text/JTextComponent.html#read%28java.io.Reader, java.lang.Object%29), removeCaretListener, removeKeymap, removeNotify, [select](../../javax/swing/text/JTextComponent.html#select%28int, int%29), selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, [contains](../../javax/swing/JComponent.html#contains%28int, int%29), createToolTip, disable, enable, [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, boolean, boolean%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, char, char%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, int, int%29), [fireVetoableChange](../../javax/swing/JComponent.html#fireVetoableChange%28java.lang.String, java.lang.Object, java.lang.Object%29), getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, [paintImmediately](../../javax/swing/JComponent.html#paintImmediately%28int, int, int, int%29), paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, [processKeyBinding](../../javax/swing/JComponent.html#processKeyBinding%28javax.swing.KeyStroke, java.awt.event.KeyEvent, int, boolean%29), processKeyEvent, processMouseEvent, processMouseMotionEvent, [putClientProperty](../../javax/swing/JComponent.html#putClientProperty%28java.lang.Object, java.lang.Object%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, javax.swing.KeyStroke, int%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int%29), removeAncestorListener, removeVetoableChangeListener, [repaint](../../javax/swing/JComponent.html#repaint%28long, int, int, int, int%29), repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, [reshape](../../javax/swing/JComponent.html#reshape%28int, int, int, int%29), revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, [setFocusTraversalKeys](../../javax/swing/JComponent.html#setFocusTraversalKeys%28int, java.util.Set%29), setFont, setForeground, setInheritsPopupMenu, [setInputMap](../../javax/swing/JComponent.html#setInputMap%28int, javax.swing.InputMap%29), setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, [add](../../java/awt/Container.html#add%28java.awt.Component, int%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object, int%29), [add](../../java/awt/Container.html#add%28java.lang.String, java.awt.Component%29), addContainerListener, [addImpl](../../java/awt/Container.html#addImpl%28java.awt.Component, java.lang.Object, int%29), addPropertyChangeListener, [addPropertyChangeListener](../../java/awt/Container.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, [findComponentAt](../../java/awt/Container.html#findComponentAt%28int, int%29), findComponentAt, getComponent, [getComponentAt](../../java/awt/Container.html#getComponentAt%28int, int%29), getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, [list](../../java/awt/Container.html#list%28java.io.PrintStream, int%29), [list](../../java/awt/Container.html#list%28java.io.PrintWriter, int%29), [locate](../../java/awt/Container.html#locate%28int, int%29), minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, [setComponentZOrder](../../java/awt/Container.html#setComponentZOrder%28java.awt.Component, int%29), setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
[action](../../java/awt/Component.html#action%28java.awt.Event, java.lang.Object%29), add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, java.awt.image.ImageObserver%29), [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), [coalesceEvents](../../java/awt/Component.html#coalesceEvents%28java.awt.AWTEvent, java.awt.AWTEvent%29), contains, createImage, [createImage](../../java/awt/Component.html#createImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int, java.awt.ImageCapabilities%29), disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, byte, byte%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, double, double%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, float, float%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, long, long%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, java.lang.Object, java.lang.Object%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, short, short%29), getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, [gotFocus](../../java/awt/Component.html#gotFocus%28java.awt.Event, java.lang.Object%29), handleEvent, hasFocus, hide, [imageUpdate](../../java/awt/Component.html#imageUpdate%28java.awt.Image, int, int, int, int, int%29), [inside](../../java/awt/Component.html#inside%28int, int%29), isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, [keyDown](../../java/awt/Component.html#keyDown%28java.awt.Event, int%29), [keyUp](../../java/awt/Component.html#keyUp%28java.awt.Event, int%29), list, list, list, location, [lostFocus](../../java/awt/Component.html#lostFocus%28java.awt.Event, java.lang.Object%29), [mouseDown](../../java/awt/Component.html#mouseDown%28java.awt.Event, int, int%29), [mouseDrag](../../java/awt/Component.html#mouseDrag%28java.awt.Event, int, int%29), [mouseEnter](../../java/awt/Component.html#mouseEnter%28java.awt.Event, int, int%29), [mouseExit](../../java/awt/Component.html#mouseExit%28java.awt.Event, int, int%29), [mouseMove](../../java/awt/Component.html#mouseMove%28java.awt.Event, int, int%29), [mouseUp](../../java/awt/Component.html#mouseUp%28java.awt.Event, int, int%29), [move](../../java/awt/Component.html#move%28int, int%29), nextFocus, paintAll, postEvent, [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, java.awt.image.ImageObserver%29), [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), repaint, [repaint](../../java/awt/Component.html#repaint%28int, int, int, int%29), repaint, resize, [resize](../../java/awt/Component.html#resize%28int, int%29), [setBounds](../../java/awt/Component.html#setBounds%28int, int, int, int%29), setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, [setLocation](../../java/awt/Component.html#setLocation%28int, int%29), setLocation, setName, setSize, [setSize](../../java/awt/Component.html#setSize%28int, int%29), show, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29)
Constructor Detail

JTextPane

public JTextPane()

Creates a new JTextPane. A new instance ofStyledEditorKit is created and set, and the document model set to null.


JTextPane

public JTextPane(StyledDocument doc)

Creates a new JTextPane, with a specified document model. A new instance of javax.swing.text.StyledEditorKit is created and set.

Parameters:

doc - the document model

Method Detail

getUIClassID

public String getUIClassID()

Returns the class ID for the UI.

Overrides:

[getUIClassID](../../javax/swing/JEditorPane.html#getUIClassID%28%29) in class [JEditorPane](../../javax/swing/JEditorPane.html "class in javax.swing")

Returns:

the string "TextPaneUI"

See Also:

JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)


setDocument

public void setDocument(Document doc)

Associates the editor with a text document. This must be a StyledDocument.

Overrides:

[setDocument](../../javax/swing/text/JTextComponent.html#setDocument%28javax.swing.text.Document%29) in class [JTextComponent](../../javax/swing/text/JTextComponent.html "class in javax.swing.text")

Parameters:

doc - the document to display/edit

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if doc can't be narrowed to a StyledDocument which is the required type of model for this text component

See Also:

JTextComponent.getDocument()


setStyledDocument

public void setStyledDocument(StyledDocument doc)

Associates the editor with a text document. The currently registered factory is used to build a view for the document, which gets displayed by the editor.

Parameters:

doc - the document to display/edit


getStyledDocument

public StyledDocument getStyledDocument()

Fetches the model associated with the editor.

Returns:

the model


replaceSelection

public void replaceSelection(String content)

Replaces the currently selected content with new content represented by the given string. If there is no selection this amounts to an insert of the given text. If there is no replacement text this amounts to a removal of the current selection. The replacement text will have the attributes currently defined for input at the point of insertion. If the document is not editable, beep and return.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Overrides:

[replaceSelection](../../javax/swing/JEditorPane.html#replaceSelection%28java.lang.String%29) in class [JEditorPane](../../javax/swing/JEditorPane.html "class in javax.swing")

Parameters:

content - the content to replace the selection with


insertComponent

public void insertComponent(Component c)

Inserts a component into the document as a replacement for the currently selected content. If there is no selection the component is effectively inserted at the current position of the caret. This is represented in the associated document as an attribute of one character of content.

The component given is the actual component used by the JTextPane. Since components cannot be a child of more than one container, this method should not be used in situations where the model is shared by text components.

The component is placed relative to the text baseline according to the value returned by Component.getAlignmentY. For Swing components this value can be conveniently set using the methodJComponent.setAlignmentY. For example, setting a value of 0.75 will cause 75 percent of the component to be above the baseline, and 25 percent of the component to be below the baseline.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:

c - the component to insert


insertIcon

public void insertIcon(Icon g)

Inserts an icon into the document as a replacement for the currently selected content. If there is no selection the icon is effectively inserted at the current position of the caret. This is represented in the associated document as an attribute of one character of content.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:

g - the icon to insert

See Also:

Icon


addStyle

public Style addStyle(String nm, Style parent)

Adds a new style into the logical style hierarchy. Style attributes resolve from bottom up so an attribute specified in a child will override an attribute specified in the parent.

Parameters:

nm - the name of the style (must be unique within the collection of named styles). The name may be null if the style is unnamed, but the caller is responsible for managing the reference returned as an unnamed style can't be fetched by name. An unnamed style may be useful for things like character attribute overrides such as found in a style run.

parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style.

Returns:

the new Style


removeStyle

public void removeStyle(String nm)

Removes a named non-null style previously added to the document.

Parameters:

nm - the name of the style to remove


getStyle

public Style getStyle(String nm)

Fetches a named non-null style previously added.

Parameters:

nm - the name of the style

Returns:

the Style


setLogicalStyle

public void setLogicalStyle(Style s)

Sets the logical style to use for the paragraph at the current caret position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in term may resolve through some hierarchy completely independent of the element hierarchy in the document.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:

s - the logical style to assign to the paragraph, or null for no style


getLogicalStyle

public Style getLogicalStyle()

Fetches the logical style assigned to the paragraph represented by the current position of the caret, or null.

Returns:

the Style


getCharacterAttributes

public AttributeSet getCharacterAttributes()

Fetches the character attributes in effect at the current location of the caret, or null.

Returns:

the attributes, or null


setCharacterAttributes

public void setCharacterAttributes(AttributeSet attr, boolean replace)

Applies the given attributes to character content. If there is a selection, the attributes are applied to the selection range. If there is no selection, the attributes are applied to the input attribute set which defines the attributes for any new text that gets inserted.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:

attr - the attributes

replace - if true, then replace the existing attributes first


getParagraphAttributes

public AttributeSet getParagraphAttributes()

Fetches the current paragraph attributes in effect at the location of the caret, or null if none.

Returns:

the attributes


setParagraphAttributes

public void setParagraphAttributes(AttributeSet attr, boolean replace)

Applies the given attributes to paragraphs. If there is a selection, the attributes are applied to the paragraphs that intersect the selection. If there is no selection, the attributes are applied to the paragraph at the current caret position.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:

attr - the non-null attributes

replace - if true, replace the existing attributes first


getInputAttributes

public MutableAttributeSet getInputAttributes()

Gets the input attributes for the pane.

Returns:

the attributes


getStyledEditorKit

protected final StyledEditorKit getStyledEditorKit()

Gets the editor kit.

Returns:

the editor kit


createDefaultEditorKit

protected EditorKit createDefaultEditorKit()

Creates the EditorKit to use by default. This is implemented to return javax.swing.text.StyledEditorKit.

Overrides:

[createDefaultEditorKit](../../javax/swing/JEditorPane.html#createDefaultEditorKit%28%29) in class [JEditorPane](../../javax/swing/JEditorPane.html "class in javax.swing")

Returns:

the editor kit


setEditorKit

public final void setEditorKit(EditorKit kit)

Sets the currently installed kit for handling content. This is the bound property that establishes the content type of the editor.

Overrides:

[setEditorKit](../../javax/swing/JEditorPane.html#setEditorKit%28javax.swing.text.EditorKit%29) in class [JEditorPane](../../javax/swing/JEditorPane.html "class in javax.swing")

Parameters:

kit - the desired editor behavior

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if kit is not aStyledEditorKit

See Also:

JEditorPane.getEditorKit()


paramString

protected String paramString()

Returns a string representation of this JTextPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:

[paramString](../../javax/swing/JEditorPane.html#paramString%28%29) in class [JEditorPane](../../javax/swing/JEditorPane.html "class in javax.swing")

Returns:

a string representation of this JTextPane



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.