|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
![]()
![]()
![]()
javax.swing.text.JTextComponent
![]()
![]()
![]()
javax.swing.JEditorPane
![]()
![]()
![]()
javax.swing.JTextPane
, MenuContainer
, Serializable
, Accessible
, Scrollable

public class JTextPane

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.
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
.
StyledEditorKit
,
Serialized Form| Nested Class Summary |
|---|
Nested classes/interfaces inherited from class javax.swing.JEditorPane ![]() |
|---|
JEditorPane.AccessibleJEditorPane |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent ![]() |
|---|
JTextComponent.AccessibleJTextComponent |
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 |
| Field Summary |
|---|
Fields inherited from class javax.swing.JEditorPane ![]() |
|---|
HONOR_DISPLAY_PROPERTIES |
Fields inherited from class javax.swing.text.JTextComponent ![]() |
|---|
DEFAULT_KEYMAP |
Fields inherited from class javax.swing.JComponent ![]() |
|---|
accessibleContext |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JTextPane
Creates a new JTextPane. |
|
JTextPane
Creates a new JTextPane, with a specified document model. |
|
| Method Summary | |
|---|---|
Style |
addStyle
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
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
Inserts a component into the document as a replacement for the currently selected content. |
void |
insertIcon
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
Removes a named non- null style previously added to
the document. |
void |
replaceSelection
Replaces the currently selected content with new content represented by the given string. |
void |
setCharacterAttributes
Applies the given attributes to character content. |
void |
setDocument
Associates the editor with a text document. |
void |
setEditorKit
Sets the currently installed kit for handling content. |
void |
setLogicalStyle
Sets the logical style to use for the paragraph at the current caret position. |
void |
setParagraphAttributes
Applies the given attributes to paragraphs. |
void |
setStyledDocument
Associates the editor with a text document. |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Constructor Detail |
|---|

public JTextPane()
JTextPane. A new instance of
StyledEditorKit is
created and set, and the document model set to null.

public JTextPane(StyledDocument![]()
![]()
doc)
JTextPane, with a specified document model.
A new instance of javax.swing.text.StyledEditorKit
is created and set.
doc - the document model| Method Detail |
|---|

public String![]()
![]()
getUIClassID()
getUIClassID

in class JEditorPane

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


public void setDocument(Document![]()
![]()
doc)
StyledDocument.
setDocument

in class JTextComponent

doc - the document to display/edit
IllegalArgumentException

- if doc can't
be narrowed to a StyledDocument which is the
required type of model for this text componentJTextComponent.getDocument()


public void setStyledDocument(StyledDocument![]()
![]()
doc)
doc - the document to display/edit

public StyledDocument![]()
![]()
getStyledDocument()

public void replaceSelection(String![]()
![]()
content)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
replaceSelection

in class JEditorPane

content - the content to replace the selection with

public void insertComponent(Component![]()
![]()
c)
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 method
JComponent.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.
c - the component to insert

public void insertIcon(Icon![]()
![]()
g)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
g - the icon to insertIcon


public Style![]()
![]()
addStyle(String
![]()
![]()
nm, Style
![]()
![]()
parent)
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.
Style

public void removeStyle(String![]()
![]()
nm)
null style previously added to
the document.
nm - the name of the style to remove

public Style![]()
![]()
getStyle(String
![]()
![]()
nm)
null style previously added.
nm - the name of the style
Style

public void setLogicalStyle(Style![]()
![]()
s)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
s - the logical style to assign to the paragraph,
or null for no style

public Style![]()
![]()
getLogicalStyle()
null.
Style

public AttributeSet![]()
![]()
getCharacterAttributes()
null.
null

public void setCharacterAttributes(AttributeSet![]()
![]()
attr, boolean replace)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
attr - the attributesreplace - if true, then replace the existing attributes first

public AttributeSet![]()
![]()
getParagraphAttributes()
null if none.

public void setParagraphAttributes(AttributeSet![]()
![]()
attr, boolean replace)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
attr - the non-null attributesreplace - if true, replace the existing attributes first

public MutableAttributeSet![]()
![]()
getInputAttributes()

protected final StyledEditorKit![]()
![]()
getStyledEditorKit()

protected EditorKit![]()
![]()
createDefaultEditorKit()
EditorKit to use by default. This
is implemented to return javax.swing.text.StyledEditorKit.
createDefaultEditorKit

in class JEditorPane


public final void setEditorKit(EditorKit![]()
![]()
kit)
setEditorKit

in class JEditorPane

kit - the desired editor behavior
IllegalArgumentException

- if kit is not a
StyledEditorKitJEditorPane.getEditorKit()


protected String![]()
![]()
paramString()
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.
paramString

in class JEditorPane

JTextPane
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||