|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JEditorPane
javax.swing.JTextPane
public class JTextPane
A powerful text component that supports styled content as well as
embedding images and components. It is entirely based on a
StyledDocument
content model and a 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.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 with a null document. |
|
JTextPane(StyledDocument document)
Creates a new JTextPane and sets the specified
document . |
Method Summary | |
---|---|
Style |
addStyle(String nm,
Style parent)
Adds a style into the style hierarchy. |
protected EditorKit |
createDefaultEditorKit()
Creates the default EditorKit that is used in
JTextPane s. |
AttributeSet |
getCharacterAttributes()
Returns the text attributes for the character at the current caret position. |
MutableAttributeSet |
getInputAttributes()
Returns the attributes that are applied to newly inserted text. |
Style |
getLogicalStyle()
Returns the logical style of the paragraph at the current caret position. |
AttributeSet |
getParagraphAttributes()
Returns the text attributes of the paragraph at the current caret position. |
Style |
getStyle(String nm)
Looks up and returns a named Style . |
StyledDocument |
getStyledDocument()
Returns the StyledDocument that is the content model for
this JTextPane . |
protected StyledEditorKit |
getStyledEditorKit()
Returns the StyledEditorKit that is currently used by this
JTextPane . |
String |
getUIClassID()
Returns the UI class ID. |
void |
insertComponent(Component component)
Inserts an AWT or Swing component into the text at the current caret position. |
void |
insertIcon(Icon icon)
Inserts an Icon into the text at the current caret position. |
protected String |
paramString()
Returns a param string that can be used for debugging. |
void |
removeStyle(String nm)
Removes a named Style from the style hierarchy. |
void |
replaceSelection(String content)
Replaces the currently selected text with the specified content . |
void |
setCharacterAttributes(AttributeSet attribute,
boolean replace)
Sets text attributes for the current selection. |
void |
setDocument(Document document)
Sets the content model for this JTextPane . |
void |
setEditorKit(EditorKit editor)
Sets the EditorKit to use for this JTextPane . |
void |
setLogicalStyle(Style style)
Sets the logical style for the paragraph at the current caret position. |
void |
setParagraphAttributes(AttributeSet attribute,
boolean replace)
Sets text attributes for the paragraph at the current selection. |
void |
setStyledDocument(StyledDocument document)
Sets the content model for this JTextPane . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JTextPane()
JTextPane
with a null
document.
public JTextPane(StyledDocument document)
JTextPane
and sets the specified
document
.
document
- the content model to useMethod Detail |
---|
public String getUIClassID()
TextPaneUI
.
getUIClassID
in class JEditorPane
TextPaneUI
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void setDocument(Document document)
JTextPane
.
JTextPane
can only be used with StyledDocument
s,
if you try to set a different type of Document
, an
IllegalArgumentException
is thrown.
setDocument
in class JTextComponent
document
- the content model to set
IllegalArgumentException
- if document
is not an
instance of StyledDocument
setStyledDocument(javax.swing.text.StyledDocument)
public StyledDocument getStyledDocument()
StyledDocument
that is the content model for
this JTextPane
. This is a typed wrapper for
JTextComponent.getDocument()
.
JTextPane
public void setStyledDocument(StyledDocument document)
JTextPane
.
document
- the content model to setpublic void replaceSelection(String content)
content
. If there is no selected text, this results
in a simple insertion at the current caret position. If there is
no content
specified, this results in the selection
beeing deleted.
replaceSelection
in class JEditorPane
content
- the text with which the selection is replacedpublic void insertComponent(Component component)
component
- the component to be insertedpublic void insertIcon(Icon icon)
Icon
into the text at the current caret position.
icon
- the Icon
to be insertedpublic Style addStyle(String nm, Style parent)
parent
style, if one is specified.
While it is legal to add nameless styles (nm == null
nm
- the name of the style or null
if the style should
be unnamedparent
- the parent in which unspecified style attributes are
resolved, or null
if that is not necessary
Style
public void removeStyle(String nm)
Style
from the style hierarchy.
nm
- the name of the Style
to be removedpublic Style getStyle(String nm)
Style
.
nm
- the name of the Style
Style
of null
if no such
Style
existspublic Style getLogicalStyle()
public void setLogicalStyle(Style style)
style
- the style to set for the current paragraphpublic AttributeSet getCharacterAttributes()
public void setCharacterAttributes(AttributeSet attribute, boolean replace)
attribute
- the text attributes to setreplace
- if true
, the attributes of the current
selection are overridden, otherwise they are mergedgetInputAttributes()
public AttributeSet getParagraphAttributes()
public void setParagraphAttributes(AttributeSet attribute, boolean replace)
attribute
- the text attributes to setreplace
- if true
, the attributes of the current
selection are overridden, otherwise they are mergedpublic MutableAttributeSet getInputAttributes()
MutableAttributeSet
, so you can easily modify these
attributes.
protected final StyledEditorKit getStyledEditorKit()
StyledEditorKit
that is currently used by this
JTextPane
.
StyledEditorKit
of this
JTextPane
protected EditorKit createDefaultEditorKit()
EditorKit
that is used in
JTextPane
s. This is an instance of StyledEditorKit
.
createDefaultEditorKit
in class JEditorPane
EditorKit
that is used in
JTextPane
spublic final void setEditorKit(EditorKit editor)
EditorKit
to use for this JTextPane
.
JTextPane
s can only handle StyledEditorKit
s,
if client programs try to set a different type of EditorKit
then an IllegalArgumentException is thrown
setEditorKit
in class JEditorPane
editor
- the EditorKit
to set
IllegalArgumentException
- if editor
is no
StyledEditorKit
protected String paramString()
paramString
in class JEditorPane
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |