public class

StyledEditorKit

extends DefaultEditorKit
java.lang.Object
   ↳ javax.swing.text.EditorKit
     ↳ javax.swing.text.DefaultEditorKit
       ↳ javax.swing.text.StyledEditorKit
Known Direct Subclasses

Class Overview

This is the set of things needed by a text component to be a reasonably functioning editor for some type of text document. This implementation provides a default implementation which treats text as styled text and provides a minimal set of actions for editing styled text.

Summary

Nested Classes
class StyledEditorKit.AlignmentAction An action to set paragraph alignment. 
class StyledEditorKit.BoldAction An action to toggle the bold attribute. 
class StyledEditorKit.FontFamilyAction An action to set the font family in the associated JEditorPane. 
class StyledEditorKit.FontSizeAction An action to set the font size in the associated JEditorPane. 
class StyledEditorKit.ForegroundAction An action to set foreground color. 
class StyledEditorKit.ItalicAction An action to toggle the italic attribute. 
class StyledEditorKit.StyledTextAction An action that assumes it's being fired on a JEditorPane with a StyledEditorKit (or subclass) installed. 
class StyledEditorKit.UnderlineAction An action to toggle the underline attribute. 
[Expand]
Inherited Constants
From class javax.swing.text.DefaultEditorKit
Public Constructors
StyledEditorKit()
Creates a new EditorKit used for styled documents.
Public Methods
Object clone()
Creates a copy of the editor kit.
Document createDefaultDocument()
Creates an uninitialized text storage model that is appropriate for this type of editor.
void deinstall(JEditorPane c)
Called when the kit is being removed from the JEditorPane.
Action[] getActions()
Fetches the command list for the editor.
Element getCharacterAttributeRun()
Fetches the element representing the current run of character attributes for the caret.
MutableAttributeSet getInputAttributes()
Gets the input attributes for the pane.
ViewFactory getViewFactory()
Fetches a factory that is suitable for producing views of any models that are produced by this kit.
void install(JEditorPane c)
Called when the kit is being installed into a JEditorPane.
Protected Methods
void createInputAttributes(Element element, MutableAttributeSet set)
Copies the key/values in elements AttributeSet into set.
[Expand]
Inherited Methods
From class javax.swing.text.DefaultEditorKit
From class javax.swing.text.EditorKit
From class java.lang.Object

Public Constructors

public StyledEditorKit ()

Creates a new EditorKit used for styled documents.

Public Methods

public Object clone ()

Creates a copy of the editor kit.

Returns
  • the copy

public Document createDefaultDocument ()

Creates an uninitialized text storage model that is appropriate for this type of editor.

Returns
  • the model

public void deinstall (JEditorPane c)

Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached.

Parameters
c the JEditorPane

public Action[] getActions ()

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

Returns
  • the command list

public Element getCharacterAttributeRun ()

Fetches the element representing the current run of character attributes for the caret.

Returns
  • the element

public MutableAttributeSet getInputAttributes ()

Gets the input attributes for the pane. When the caret moves and there is no selection, the input attributes are automatically mutated to reflect the character attributes of the current caret location. The styled editing actions use the input attributes to carry out their actions.

Returns
  • the attribute set

public ViewFactory getViewFactory ()

Fetches a factory that is suitable for producing views of any models that are produced by this kit. This is implemented to return View implementations for the following kinds of elements:

  • AbstractDocument.ContentElementName
  • AbstractDocument.ParagraphElementName
  • AbstractDocument.SectionElementName
  • StyleConstants.ComponentElementName
  • StyleConstants.IconElementName

Returns
  • the factory

public void install (JEditorPane c)

Called when the kit is being installed into a JEditorPane.

Parameters
c the JEditorPane

Protected Methods

protected void createInputAttributes (Element element, MutableAttributeSet set)

Copies the key/values in elements AttributeSet into set. This does not copy component, icon, or element names attributes. Subclasses may wish to refine what is and what isn't copied here. But be sure to first remove all the attributes that are in set.

This is called anytime the caret moves over a different location.