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.


Constructor Index

 o JTextPane()
 o JTextPane(Document, StyleContext)

Method Index

 o addStyle(String, Style)
Add a new style into the logical style hierarchy.
 o bold()
Changes the current selection to be bold.
 o clearAttributes()
Removes attribute definitions for the current selection.
 o createDefaultModel()
Create the default model to be used when constructing a JTextPane without an explicitly specified model.
 o getActions()
Fetch the command list for the editor.
 o getInputStyle()
Fetch the style in effect act the caret position.
 o getLogicalStyle()
Fetch the logical style assigned to the paragraph represented by the current position of the caret.
 o getStyle(int)
Fetch the style in effect at the given location which is overriding the logical style (ie it resolves through the logical style).
 o getStyle(String)
Fetch a named style previously added.
 o getStyleContext()
Fetch the style collection to use.
 o insertComponent(Component)
Insert a component into the document as a replacement for the currently selected content.
 o insertIcon(Icon)
Insert a icon into the document as a replacement for the currently selected content.
 o italic()
Changes the current selection to be italic.
 o removeStyle(String)
Remove a named style previously added to the document.
 o replaceSelection(String)
Replace the currently selected content with new content represented by the given string.
 o setFontFamily(String)
Changes the font family of the current selection to be the given size.
 o setFontSize(int)
Changes the font size of the current selection to be the given size.
 o setForeground(Color)
Changes the text color of the current selection to be the given color.
 o setLogicalStyle(Style)
Set the logical style to use for the paragraph at the current caret position.
 o setStyleContext(StyleContext)
Set the collection of styles to use.
 o setUI(TextUI)
Set the user-interface factory for this text-oriented editor
 o updateUI()
Reload the pluggable UI.

Constructors

 o JTextPane
 public JTextPane()
 o JTextPane
 public JTextPane(Document doc,
                  StyleContext styles)

Methods

 o updateUI
 public void updateUI()
Reload the pluggable UI. The key used to fetch the new interface is TextPaneUI.

Overrides:
updateUI in class JComponent
 o setUI
 public void setUI(TextUI ui)
Set the user-interface factory for this text-oriented editor

Overrides:
setUI in class JTextComponent
 o 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
 o 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.
 o 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
 o 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.
 o removeStyle
 public void removeStyle(String nm)
Remove a named style previously added to the document.

Parameters:
nm - The name of the style to remove
 o getStyle
 public Style getStyle(String nm)
Fetch a named style previously added.

Parameters:
nm - The name of the style
 o 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.
 o getLogicalStyle
 public Style getLogicalStyle()
Fetch the logical style assigned to the paragraph represented by the current position of the caret.

 o 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).

 o 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.

 o 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.

 o 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.

 o 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.

 o 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
 o 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
 o 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
 o getStyleContext
 public StyleContext getStyleContext()
Fetch the style collection to use.

 o setStyleContext
 public void setStyleContext(StyleContext sc)
Set the collection of styles to use.

 o 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
 o 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