# Class StyledEditorKit

java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
javax.swing.text.StyledEditorKit

All Implemented Interfaces:
  `Serializable, Cloneable`

Direct Known Subclasses:
  `HTMLEditorKit, RTFEditorKit`

public class StyledEditorKit extends DefaultEditorKit
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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`StyledEditorKit.AlignmentAction`
An action to set paragraph alignment.
`static class`
`StyledEditorKit.BoldAction`
An action to toggle the bold attribute.
`static class`
`StyledEditorKit.FontFamilyAction`
An action to set the font family in the associated JEditorPane.
`static class`
`StyledEditorKit.FontSizeAction`
An action to set the font size in the associated JEditorPane.
`static class`
`StyledEditorKit.ForegroundAction`
An action to set foreground color.
`static class`
`StyledEditorKit.ItalicAction`
An action to toggle the italic attribute.
`static class`
`StyledEditorKit.StyledTextAction`
An action that assumes it's being fired on a JEditorPane with a StyledEditorKit (or subclass) installed.
`static class`
`StyledEditorKit.UnderlineAction`
An action to toggle the underline attribute.

### Nested classes/interfaces declared in class DefaultEditorKit

`DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction`
Modifier and Type
Class
Description
`static class`
`DefaultEditorKit.BeepAction`
Creates a beep.
`static class`
`DefaultEditorKit.CopyAction`
Copies the selected region and place its contents into the system clipboard.
`static class`
`DefaultEditorKit.CutAction`
Cuts the selected region and place its contents into the system clipboard.
`static class`
`DefaultEditorKit.DefaultKeyTypedAction`
The action that is executed by default if a key typed event is received and there is no keymap entry.
`static class`
`DefaultEditorKit.InsertBreakAction`
Places a line/paragraph break into the document.
`static class`
`DefaultEditorKit.InsertContentAction`
Places content into the associated document.
`static class`
`DefaultEditorKit.InsertTabAction`
Places a tab character into the document.
`static class`
`DefaultEditorKit.PasteAction`
Pastes the contents of the system clipboard into the selected region, or before the caret if nothing is selected.

## Field Summary

### Fields declared in class DefaultEditorKit

`backwardAction, beepAction, beginAction, beginLineAction, beginLineUpAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, endLineDownAction, 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`
Modifier and Type
Field
Description
`static final String`
`backwardAction`
Name of the Action for moving the caret logically backward one position.
`static final String`
`beepAction`
Name of the action to create a beep.
`static final String`
`beginAction`
Name of the `Action` for moving the caret to the beginning of the document.
`static final String`
`beginLineAction`
Name of the `Action` for moving the caret to the beginning of a line.
`static final String`
`beginLineUpAction`
Name of the `Action` for moving the caret to the beginning of the current line or up to the beginning of the previous line if the caret is already at the beginning of the line.
`static final String`
`beginParagraphAction`
Name of the `Action` for moving the caret to the beginning of a paragraph.
`static final String`
`beginWordAction`
Name of the `Action` for moving the caret to the beginning of a word.
`static final String`
`copyAction`
Name of the action to copy the selected region and place the contents into the system clipboard.
`static final String`
`cutAction`
Name of the action to cut the selected region and place the contents into the system clipboard.
`static final String`
`defaultKeyTypedAction`
Name of the action that is executed by default if a key typed event is received and there is no keymap entry.
`static final String`
`deleteNextCharAction`
Name of the action to delete the character of content that follows the current caret position.
`static final String`
`deleteNextWordAction`
Name of the action to delete the word that follows the beginning of the selection.
`static final String`
`deletePrevCharAction`
Name of the action to delete the character of content that precedes the current caret position.
`static final String`
`deletePrevWordAction`
Name of the action to delete the word that precedes the beginning of the selection.
`static final String`
`downAction`
Name of the Action for moving the caret logically downward one position.
`static final String`
`endAction`
Name of the `Action` for moving the caret to the end of the document.
`static final String`
`endLineAction`
Name of the `Action` for moving the caret to the end of a line.
`static final String`
`endLineDownAction`
Name of the `Action` for moving the caret to the end of the current line or down to the end of the next line if the caret is already at the end of the line.
`static final String`
`EndOfLineStringProperty`
When reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".
`static final String`
`endParagraphAction`
Name of the `Action` for moving the caret to the end of a paragraph.
`static final String`
`endWordAction`
Name of the Action for moving the caret to the end of a word.
`static final String`
`forwardAction`
Name of the Action for moving the caret logically forward one position.
`static final String`
`insertBreakAction`
Name of the action to place a line/paragraph break into the document.
`static final String`
`insertContentAction`
Name of the action to place content into the associated document.
`static final String`
`insertTabAction`
Name of the action to place a tab character into the document.
`static final String`
`nextWordAction`
Name of the `Action` for moving the caret to the beginning of the next word.
`static final String`
`pageDownAction`
Name of the action to page down vertically.
`static final String`
`pageUpAction`
Name of the action to page up vertically.
`static final String`
`pasteAction`
Name of the action to paste the contents of the system clipboard into the selected region, or before the caret if nothing is selected.
`static final String`
`previousWordAction`
Name of the `Action` for moving the caret to the beginning of the previous word.
`static final String`
`readOnlyAction`
Name of the action to set the editor into read-only mode.
`static final String`
`selectAllAction`
Name of the Action for selecting the entire document
`static final String`
`selectionBackwardAction`
Name of the Action for extending the selection by moving the caret logically backward one position.
`static final String`
`selectionBeginAction`
Name of the `Action` for moving the caret to the beginning of the document.
`static final String`
`selectionBeginLineAction`
Name of the `Action` for moving the caret to the beginning of a line, extending the selection.
`static final String`
`selectionBeginParagraphAction`
Name of the `Action` for moving the caret to the beginning of a paragraph, extending the selection.
`static final String`
`selectionBeginWordAction`
Name of the `Action` for moving the caret to the beginning of a word, extending the selection.
`static final String`
`selectionDownAction`
Name of the Action for moving the caret logically downward one position, extending the selection.
`static final String`
`selectionEndAction`
Name of the Action for moving the caret to the end of the document.
`static final String`
`selectionEndLineAction`
Name of the `Action` for moving the caret to the end of a line, extending the selection.
`static final String`
`selectionEndParagraphAction`
Name of the `Action` for moving the caret to the end of a paragraph, extending the selection.
`static final String`
`selectionEndWordAction`
Name of the Action for moving the caret to the end of a word, extending the selection.
`static final String`
`selectionForwardAction`
Name of the Action for extending the selection by moving the caret logically forward one position.
`static final String`
`selectionNextWordAction`
Name of the `Action` for moving the selection to the beginning of the next word, extending the selection.
`static final String`
`selectionPreviousWordAction`
Name of the `Action` for moving the selection to the beginning of the previous word, extending the selection.
`static final String`
`selectionUpAction`
Name of the Action for moving the caret logically upward one position, extending the selection.
`static final String`
`selectLineAction`
Name of the Action for selecting a line around the caret.
`static final String`
`selectParagraphAction`
Name of the Action for selecting a paragraph around the caret.
`static final String`
`selectWordAction`
Name of the Action for selecting a word around the caret.
`static final String`
`upAction`
Name of the Action for moving the caret logically upward one position.
`static final String`
`writableAction`
Name of the action to set the editor into writeable mode.

## Constructor Summary

Constructors
Constructor
Description
`StyledEditorKit()`
Creates a new EditorKit used for styled documents.

## Method Summary

Modifier and Type
Method
Description
`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.
`protected void`
`createInputAttributes(Element element, MutableAttributeSet set)`
Copies the key/values in `element`s AttributeSet into `set`.
`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.

### Methods declared in class DefaultEditorKit

`createCaret, getContentType, read, read, write, write`
Modifier and Type
Method
Description
`Caret`
`createCaret()`
Fetches a caret that can navigate through views produced by the associated ViewFactory.
`String`
`getContentType()`
Gets the MIME type of the data that this kit represents support for.
`void`
`read(InputStream in, Document doc, int pos)`
Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.
`void`
`read(Reader in, Document doc, int pos)`
Inserts content from the given stream, which will be treated as plain text.
`void`
`write(OutputStream out, Document doc, int pos, int len)`
Writes content from a document to the given stream in a format appropriate for this kind of content handler.
`void`
`write(Writer out, Document doc, int pos, int len)`
Writes content from a document to the given stream as plain text.

### Methods declared in class Object

`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
Modifier and Type
Method
Description
`boolean`
`equals(Object obj)`
Indicates whether some other object is "equal to" this one.
`protected void`
`finalize()`
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
`final Class<?>`
`getClass()`
Returns the runtime class of this `Object`.
`int`
`hashCode()`
Returns a hash code value for this object.
`final void`
`notify()`
Wakes up a single thread that is waiting on this object's monitor.
`final void`
`notifyAll()`
Wakes up all threads that are waiting on this object's monitor.
`String`
`toString()`
Returns a string representation of the object.
`final void`
`wait()`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
`final void`
`wait(long timeoutMillis)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
`final void`
`wait(long timeoutMillis, int nanos)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

## Constructor Details

### StyledEditorKit

public StyledEditorKit()
Creates a new EditorKit used for styled documents.

## Method Details

### getInputAttributes

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

### getCharacterAttributeRun

public Element getCharacterAttributeRun()
Fetches the element representing the current run of character attributes for the caret.

Returns:
  the element

### getActions

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.

Overrides:
  `getActions` in class `DefaultEditorKit`
Returns:
  the command list

### createDefaultDocument

public Document createDefaultDocument()
Creates an uninitialized text storage model that is appropriate for this type of editor.

Overrides:
  `createDefaultDocument` in class `DefaultEditorKit`
Returns:
  the model

### install

public void install(JEditorPane c)
Called when the kit is being installed into a JEditorPane.

Overrides:
  `install` in class `EditorKit`
Parameters:
  `c` - the JEditorPane

### deinstall

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.

Overrides:
  `deinstall` in class `EditorKit`
Parameters:
  `c` - the JEditorPane

### getViewFactory

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

Overrides:
  `getViewFactory` in class `DefaultEditorKit`
Returns:
  the factory

### clone

public Object clone()
Creates a copy of the editor kit.

Overrides:
  `clone` in class `EditorKit`
Returns:
  the copy
See Also:
  - `Cloneable`

### createInputAttributes

protected void createInputAttributes(Element element, MutableAttributeSet set)
Copies the key/values in `element`s 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.

Parameters:
  `element` - the element
  `set` - the attributes