javax.swing.text
Class StyledEditorKit

java.lang.Object
  extended by javax.swing.text.EditorKit
      extended by javax.swing.text.DefaultEditorKit
          extended by javax.swing.text.StyledEditorKit
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
HTMLEditorKit, RTFEditorKit

public class StyledEditorKit
extends DefaultEditorKit

An EditorKit that supports editing styled text.

See Also:
Serialized Form

Nested Class Summary
static class StyledEditorKit.AlignmentAction
          Sets the alignment attribute on the selected text.
static class StyledEditorKit.BoldAction
          Toggles the bold attribute for the selected text.
static class StyledEditorKit.FontFamilyAction
          Sets the font family attribute on the selected text.
static class StyledEditorKit.FontSizeAction
          Sets the font size attribute on the selected text.
static class StyledEditorKit.ForegroundAction
          Sets the foreground color attribute on the selected text.
static class StyledEditorKit.ItalicAction
          Toggles the italic attribute for the selected text.
static class StyledEditorKit.StyledTextAction
          The abstract superclass of all styled TextActions.
static class StyledEditorKit.UnderlineAction
          Toggles the underline attribute for the selected text.
 
Nested classes/interfaces inherited from class javax.swing.text.DefaultEditorKit
DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction
 
Field Summary
 
Fields inherited from class javax.swing.text.DefaultEditorKit
backwardAction, beepAction, beginAction, beginLineAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deletePrevCharAction, downAction, endAction, endLineAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction
 
Constructor Summary
StyledEditorKit()
          Creates a new instance of StyledEditorKit.
 
Method Summary
 Object clone()
          Creates an exact copy of this StyledEditorKit.
 Document createDefaultDocument()
          Creates the default Document supported by this EditorKit.
protected  void createInputAttributes(Element element, MutableAttributeSet set)
          Copies the text attributes from element to set.
 void deinstall(JEditorPane component)
          Deinstalls this EditorKit from the specified JEditorPane.
 Action[] getActions()
          Returns the Actions supported by this EditorKit.
 Element getCharacterAttributeRun()
          Returns the Element that represents the character run at the current caret position.
 MutableAttributeSet getInputAttributes()
          Returns the current input attributes.
 ViewFactory getViewFactory()
          Returns a ViewFactory that is able to create Views for Elements that are supported by this EditorKit, namely the following types of Elements: AbstractDocument.ContentElementName AbstractDocument.ParagraphElementName AbstractDocument.SectionElementName StyleConstants.ComponentElementName StyleConstants.IconElementName
 void install(JEditorPane component)
          Installs this EditorKit on the specified JEditorPane.
 
Methods inherited from class javax.swing.text.DefaultEditorKit
createCaret, getContentType, read, read, write, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyledEditorKit

public StyledEditorKit()
Creates a new instance of StyledEditorKit.

Method Detail

clone

public Object clone()
Creates an exact copy of this StyledEditorKit.

Overrides:
clone in class EditorKit
Returns:
an exact copy of this StyledEditorKit
See Also:
Cloneable

getActions

public Action[] getActions()
Returns the Actions supported by this EditorKit. This includes the StyledEditorKit.BoldAction, StyledEditorKit.ItalicAction and StyledEditorKit.UnderlineAction as well as the Actions supported by DefaultEditorKit. The other Actions of StyledEditorKit are not returned here, since they require a parameter and thus custom instantiation.

Overrides:
getActions in class DefaultEditorKit
Returns:
the Actions supported by this EditorKit

getInputAttributes

public MutableAttributeSet getInputAttributes()
Returns the current input attributes. These are automatically set on any newly inserted content, if not specified otherwise.

Returns:
the current input attributes

getCharacterAttributeRun

public Element getCharacterAttributeRun()
Returns the Element that represents the character run at the current caret position.

Returns:
the Element that represents the character run at the current caret position

createDefaultDocument

public Document createDefaultDocument()
Creates the default Document supported by this EditorKit. This is an instance of DefaultStyledDocument in this case but may be overridden by subclasses.

Overrides:
createDefaultDocument in class DefaultEditorKit
Returns:
an instance of DefaultStyledDocument

install

public void install(JEditorPane component)
Installs this EditorKit on the specified JEditorPane. This basically involves setting up required listeners on the JEditorPane.

Overrides:
install in class EditorKit
Parameters:
component - the JEditorPane to install this EditorKit on

deinstall

public void deinstall(JEditorPane component)
Deinstalls this EditorKit from the specified JEditorPane. This basically involves removing all listeners from JEditorPane that have been set up by this EditorKit.

Overrides:
deinstall in class EditorKit
Parameters:
component - the JEditorPane from which to deinstall this EditorKit

getViewFactory

public ViewFactory getViewFactory()
Returns a ViewFactory that is able to create Views for Elements that are supported by this EditorKit, namely the following types of Elements:

Overrides:
getViewFactory in class DefaultEditorKit
Returns:
a ViewFactory that is able to create Views for Elements that are supported by this EditorKit

createInputAttributes

protected void createInputAttributes(Element element,
                                     MutableAttributeSet set)
Copies the text attributes from element to set. This is called everytime when the caret position changes to keep track of the current input attributes. The attributes in set are cleaned before adding the attributes of element. This method filters out attributes for element names, Icons and Components.

Parameters:
element - the Element from which to copy the text attributes
set - the inputAttributes to copy the attributes to