All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JTextPane
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.sun.java.swing.text.JTextComponent
|
+----com.sun.java.swing.JTextPane
- public class JTextPane
- extends JTextComponent
A text component that can be marked up with attributes that are
represented graphically.
-
JTextPane()
-
-
JTextPane(Document, StyleContext)
-
-
addStyle(String, Style)
- Add a new style into the logical style hierarchy.
-
bold()
- Changes the current selection to be bold.
-
clearAttributes()
- Removes attribute definitions for the current selection.
-
createDefaultModel()
- Create the default model to be used when constructing a
JTextPane without an explicitly specified model.
-
getActions()
- Fetch the command list for the editor.
-
getInputStyle()
- Fetch the style in effect act the caret position.
-
getLogicalStyle()
-
Fetch the logical style assigned to the paragraph
represented by the current position of the caret.
-
getStyle(int)
- Fetch the style in effect at the given location
which is overriding the logical style (ie it resolves
through the logical style).
-
getStyle(String)
- Fetch a named style previously added.
-
getStyleContext()
- Fetch the style collection to use.
-
insertComponent(Component)
- Insert a component into the document as a replacement
for the currently selected content.
-
insertIcon(Icon)
- Insert a icon into the document as a replacement
for the currently selected content.
-
italic()
- Changes the current selection to be italic.
-
removeStyle(String)
- Remove a named style previously added to the document.
-
replaceSelection(String)
- Replace the currently selected content with new content
represented by the given string.
-
setFontFamily(String)
- Changes the font family of the current selection to
be the given size.
-
setFontSize(int)
- Changes the font size of the current selection to
be the given size.
-
setForeground(Color)
- Changes the text color of the current selection to
be the given color.
-
setLogicalStyle(Style)
- Set the logical style to use for the paragraph at the
current caret position.
-
setStyleContext(StyleContext)
- Set the collection of styles to use.
-
setUI(TextUI)
- Set the user-interface factory for this text-oriented editor
-
updateUI()
- Reload the pluggable UI.
JTextPane
public JTextPane()
JTextPane
public JTextPane(Document doc,
StyleContext styles)
updateUI
public void updateUI()
- Reload the pluggable UI. The key used to fetch the
new interface is TextPaneUI.
- Overrides:
- updateUI in class JComponent
setUI
public void setUI(TextUI ui)
- Set the user-interface factory for this text-oriented editor
- Overrides:
- setUI in class JTextComponent
replaceSelection
public void replaceSelection(String content)
- Replace 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.
- Parameters:
- content - The content to replace the selection with.
- Overrides:
- replaceSelection in class JTextComponent
insertComponent
public void insertComponent(Component c)
- Insert 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.
- Parameters:
- c - The component to insert.
insertIcon
public void insertIcon(Icon g)
- Insert a 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.
- Parameters:
- g - The icon to insert.
- See Also:
- Icon
addStyle
public Style addStyle(String nm,
Style parent)
- Add 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.
removeStyle
public void removeStyle(String nm)
- Remove a named style previously added to the document.
- Parameters:
- nm - The name of the style to remove
getStyle
public Style getStyle(String nm)
- Fetch a named style previously added.
- Parameters:
- nm - The name of the style
setLogicalStyle
public void setLogicalStyle(Style s)
- Set the logical style to use for the paragraph at the
current caret position. If attributes aren't explicity 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
independant of the element hierarchy in the document.
- Parameters:
- s - The logical style to assign to the paragraph.
getLogicalStyle
public Style getLogicalStyle()
- Fetch the logical style assigned to the paragraph
represented by the current position of the caret.
getStyle
public Style getStyle(int offset)
- Fetch the style in effect at the given location
which is overriding the logical style (ie it resolves
through the logical style).
getInputStyle
public Style getInputStyle()
- Fetch the style in effect act the caret position.
It is the style used to represent attributes that will
be applied to new content that is inserted.
clearAttributes
public void clearAttributes()
- Removes attribute definitions for the current selection.
If there is no selection, the attributes are removed from
the input attributes definition.
bold
public void bold()
- Changes the current selection to be bold.
If there is no selection, the bold attribute is
set on the current input attributes definition.
italic
public void italic()
- Changes the current selection to be italic.
If there is no selection, the italic attribute is
set on the current input attributes definition.
setFontSize
public void setFontSize(int size)
- Changes the font size of the current selection to
be the given size.
- Parameters:
- size - The font size to set
setFontFamily
public void setFontFamily(String family)
- Changes the font family of the current selection to
be the given size.
- Parameters:
- family - The font family to use
setForeground
public void setForeground(Color c)
- Changes the text color of the current selection to
be the given color.
- Parameters:
- c - The color to change the text to.
- Overrides:
- setForeground in class Component
getStyleContext
public StyleContext getStyleContext()
- Fetch the style collection to use.
setStyleContext
public void setStyleContext(StyleContext sc)
- Set the collection of styles to use.
getActions
public Action[] getActions()
- Fetch the command list for the editor. This is
the list of commands supported by the superclass
augmented by the collection of commands defined
locally for style operations.
- Overrides:
- getActions in class JTextComponent
createDefaultModel
protected Document createDefaultModel()
- Create the default model to be used when constructing a
JTextPane without an explicitly specified model.
All Packages Class Hierarchy This Package Previous Next Index