public class

DefaultEditorKit

extends EditorKit
java.lang.Object
   ↳ javax.swing.text.EditorKit
     ↳ javax.swing.text.DefaultEditorKit
Known Direct Subclasses
Known Indirect 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 plain text and provides a minimal set of actions for a simple editor.

Newlines
There are two properties which deal with newlines. The system property, line.separator, is defined to be platform-dependent, either "\n", "\r", or "\r\n". There is also a property defined in DefaultEditorKit, called EndOfLineStringProperty, which is defined automatically when a document is loaded, to be the first occurrence of any of the newline characters. When a document is loaded, EndOfLineStringProperty is set appropriately, and when the document is written back out, the EndOfLineStringProperty is used. But while the document is in memory, the "\n" character is used to define a newline, regardless of how the newline is defined when the document is on disk. Therefore, for searching purposes, "\n" should always be used. When a new document is created, and the EndOfLineStringProperty has not been defined, it will use the System property when writing out the document.

Note that EndOfLineStringProperty is set on the Document using the get/putProperty methods. Subclasses may override this behavior.

Summary

Nested Classes
class DefaultEditorKit.BeepAction Creates a beep. 
class DefaultEditorKit.CopyAction Copies the selected region and place its contents into the system clipboard. 
class DefaultEditorKit.CutAction Cuts the selected region and place its contents into the system clipboard. 
class DefaultEditorKit.DefaultKeyTypedAction The action that is executed by default if a key typed event is received and there is no keymap entry. 
class DefaultEditorKit.InsertBreakAction Places a line/paragraph break into the document. 
class DefaultEditorKit.InsertContentAction Places content into the associated document. 
class DefaultEditorKit.InsertTabAction Places a tab character into the document. 
class DefaultEditorKit.PasteAction Pastes the contents of the system clipboard into the selected region, or before the caret if nothing is selected. 
Constants
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".
String backwardAction Name of the Action for moving the caret logically backward one position.
String beepAction Name of the action to create a beep.
String beginAction Name of the Action for moving the caret to the beginning of the document.
String beginLineAction Name of the Action for moving the caret to the beginning of a line.
String beginParagraphAction Name of the Action for moving the caret to the beginning of a paragraph.
String beginWordAction Name of the Action for moving the caret to the beginning of a word.
String copyAction Name of the action to copy the selected region and place the contents into the system clipboard.
String cutAction Name of the action to cut the selected region and place the contents into the system clipboard.
String defaultKeyTypedAction Name of the action that is executed by default if a key typed event is received and there is no keymap entry.
String deleteNextCharAction Name of the action to delete the character of content that follows the current caret position.
String deleteNextWordAction Name of the action to delete the word that follows the beginning of the selection.
String deletePrevCharAction Name of the action to delete the character of content that precedes the current caret position.
String deletePrevWordAction Name of the action to delete the word that precedes the beginning of the selection.
String downAction Name of the Action for moving the caret logically downward one position.
String endAction Name of the Action for moving the caret to the end of the document.
String endLineAction Name of the Action for moving the caret to the end of a line.
String endParagraphAction Name of the Action for moving the caret to the end of a paragraph.
String endWordAction Name of the Action for moving the caret to the end of a word.
String forwardAction Name of the Action for moving the caret logically forward one position.
String insertBreakAction Name of the action to place a line/paragraph break into the document.
String insertContentAction Name of the action to place content into the associated document.
String insertTabAction Name of the action to place a tab character into the document.
String nextWordAction Name of the Action for moving the caret to the beginning of the next word.
String pageDownAction Name of the action to page down vertically.
String pageUpAction Name of the action to page up vertically.
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.
String previousWordAction Name of the Action for moving the caret to the beginning of the previous word.
String readOnlyAction Name of the action to set the editor into read-only mode.
String selectAllAction Name of the Action for selecting the entire document
String selectLineAction Name of the Action for selecting a line around the caret.
String selectParagraphAction Name of the Action for selecting a paragraph around the caret.
String selectWordAction Name of the Action for selecting a word around the caret.
String selectionBackwardAction Name of the Action for extending the selection by moving the caret logically backward one position.
String selectionBeginAction Name of the Action for moving the caret to the beginning of the document.
String selectionBeginLineAction Name of the Action for moving the caret to the beginning of a line, extending the selection.
String selectionBeginParagraphAction Name of the Action for moving the caret to the beginning of a paragraph, extending the selection.
String selectionBeginWordAction Name of the Action for moving the caret to the beginning of a word, extending the selection.
String selectionDownAction Name of the Action for moving the caret logically downward one position, extending the selection.
String selectionEndAction Name of the Action for moving the caret to the end of the document.
String selectionEndLineAction Name of the Action for moving the caret to the end of a line, extending the selection.
String selectionEndParagraphAction Name of the Action for moving the caret to the end of a paragraph, extending the selection.
String selectionEndWordAction Name of the Action for moving the caret to the end of a word, extending the selection.
String selectionForwardAction Name of the Action for extending the selection by moving the caret logically forward one position.
String selectionNextWordAction Name of the Action for moving the selection to the beginning of the next word, extending the selection.
String selectionPreviousWordAction Name of the Action for moving the selection to the beginning of the previous word, extending the selection.
String selectionUpAction Name of the Action for moving the caret logically upward one position, extending the selection.
String upAction Name of the Action for moving the caret logically upward one position.
String writableAction Name of the action to set the editor into writeable mode.
Public Constructors
DefaultEditorKit()
default constructor for DefaultEditorKit
Public Methods
Caret createCaret()
Fetches a caret that can navigate through views produced by the associated ViewFactory.
Document createDefaultDocument()
Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.
Action[] getActions()
Fetches the set of commands that can be used on a text component that is using a model and view produced by this kit.
String getContentType()
Gets the MIME type of the data that this kit represents support for.
ViewFactory getViewFactory()
Fetches a factory that is suitable for producing views of any models that are produced by this kit.
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(Writer out, Document doc, int pos, int len)
Writes content from a document to the given stream 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.
[Expand]
Inherited Methods
From class javax.swing.text.EditorKit
From class java.lang.Object

Constants

public 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".

Constant Value: "__EndOfLine__"

public static final String backwardAction

Name of the Action for moving the caret logically backward one position.

See Also
Constant Value: "caret-backward"

public static final String beepAction

Name of the action to create a beep.

See Also
Constant Value: "beep"

public static final String beginAction

Name of the Action for moving the caret to the beginning of the document.

See Also
Constant Value: "caret-begin"

public static final String beginLineAction

Name of the Action for moving the caret to the beginning of a line.

See Also
Constant Value: "caret-begin-line"

public static final String beginParagraphAction

Name of the Action for moving the caret to the beginning of a paragraph.

See Also
Constant Value: "caret-begin-paragraph"

public static final String beginWordAction

Name of the Action for moving the caret to the beginning of a word.

See Also
Constant Value: "caret-begin-word"

public static final String copyAction

Name of the action to copy the selected region and place the contents into the system clipboard.

Constant Value: "copy-to-clipboard"

public static final String cutAction

Name of the action to cut the selected region and place the contents into the system clipboard.

Constant Value: "cut-to-clipboard"

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

See Also
Constant Value: "default-typed"

public static final String deleteNextCharAction

Name of the action to delete the character of content that follows the current caret position.

See Also
Constant Value: "delete-next"

public static final String deleteNextWordAction

Name of the action to delete the word that follows the beginning of the selection.

Constant Value: "delete-next-word"

public static final String deletePrevCharAction

Name of the action to delete the character of content that precedes the current caret position.

See Also
Constant Value: "delete-previous"

public static final String deletePrevWordAction

Name of the action to delete the word that precedes the beginning of the selection.

Constant Value: "delete-previous-word"

public static final String downAction

Name of the Action for moving the caret logically downward one position.

See Also
Constant Value: "caret-down"

public static final String endAction

Name of the Action for moving the caret to the end of the document.

See Also
Constant Value: "caret-end"

public static final String endLineAction

Name of the Action for moving the caret to the end of a line.

See Also
Constant Value: "caret-end-line"

public static final String endParagraphAction

Name of the Action for moving the caret to the end of a paragraph.

See Also
Constant Value: "caret-end-paragraph"

public static final String endWordAction

Name of the Action for moving the caret to the end of a word.

See Also
Constant Value: "caret-end-word"

public static final String forwardAction

Name of the Action for moving the caret logically forward one position.

See Also
Constant Value: "caret-forward"

public static final String insertBreakAction

Name of the action to place a line/paragraph break into the document. If there is a selection, it is removed before the break is added.

See Also
Constant Value: "insert-break"

public static final String insertContentAction

Name of the action to place content into the associated document. If there is a selection, it is removed before the new content is added.

See Also
Constant Value: "insert-content"

public static final String insertTabAction

Name of the action to place a tab character into the document. If there is a selection, it is removed before the tab is added.

See Also
Constant Value: "insert-tab"

public static final String nextWordAction

Name of the Action for moving the caret to the beginning of the next word.

See Also
Constant Value: "caret-next-word"

public static final String pageDownAction

Name of the action to page down vertically.

See Also
Constant Value: "page-down"

public static final String pageUpAction

Name of the action to page up vertically.

See Also
Constant Value: "page-up"

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

Constant Value: "paste-from-clipboard"

public static final String previousWordAction

Name of the Action for moving the caret to the beginning of the previous word.

See Also
Constant Value: "caret-previous-word"

public static final String readOnlyAction

Name of the action to set the editor into read-only mode.

See Also
Constant Value: "set-read-only"

public static final String selectAllAction

Name of the Action for selecting the entire document

See Also
Constant Value: "select-all"

public static final String selectLineAction

Name of the Action for selecting a line around the caret.

See Also
Constant Value: "select-line"

public static final String selectParagraphAction

Name of the Action for selecting a paragraph around the caret.

See Also
Constant Value: "select-paragraph"

public static final String selectWordAction

Name of the Action for selecting a word around the caret.

See Also
Constant Value: "select-word"

public static final String selectionBackwardAction

Name of the Action for extending the selection by moving the caret logically backward one position.

See Also
Constant Value: "selection-backward"

public static final String selectionBeginAction

Name of the Action for moving the caret to the beginning of the document.

See Also
Constant Value: "selection-begin"

public static final String selectionBeginLineAction

Name of the Action for moving the caret to the beginning of a line, extending the selection.

See Also
Constant Value: "selection-begin-line"

public static final String selectionBeginParagraphAction

Name of the Action for moving the caret to the beginning of a paragraph, extending the selection.

See Also
Constant Value: "selection-begin-paragraph"

public static final String selectionBeginWordAction

Name of the Action for moving the caret to the beginning of a word, extending the selection.

See Also
Constant Value: "selection-begin-word"

public static final String selectionDownAction

Name of the Action for moving the caret logically downward one position, extending the selection.

See Also
Constant Value: "selection-down"

public static final String selectionEndAction

Name of the Action for moving the caret to the end of the document.

See Also
Constant Value: "selection-end"

public static final String selectionEndLineAction

Name of the Action for moving the caret to the end of a line, extending the selection.

See Also
Constant Value: "selection-end-line"

public static final String selectionEndParagraphAction

Name of the Action for moving the caret to the end of a paragraph, extending the selection.

See Also
Constant Value: "selection-end-paragraph"

public static final String selectionEndWordAction

Name of the Action for moving the caret to the end of a word, extending the selection.

See Also
Constant Value: "selection-end-word"

public static final String selectionForwardAction

Name of the Action for extending the selection by moving the caret logically forward one position.

See Also
Constant Value: "selection-forward"

public static final String selectionNextWordAction

Name of the Action for moving the selection to the beginning of the next word, extending the selection.

See Also
Constant Value: "selection-next-word"

public static final String selectionPreviousWordAction

Name of the Action for moving the selection to the beginning of the previous word, extending the selection.

See Also
Constant Value: "selection-previous-word"

public static final String selectionUpAction

Name of the Action for moving the caret logically upward one position, extending the selection.

See Also
Constant Value: "selection-up"

public static final String upAction

Name of the Action for moving the caret logically upward one position.

See Also
Constant Value: "caret-up"

public static final String writableAction

Name of the action to set the editor into writeable mode.

See Also
Constant Value: "set-writable"

Public Constructors

public DefaultEditorKit ()

default constructor for DefaultEditorKit

Public Methods

public Caret createCaret ()

Fetches a caret that can navigate through views produced by the associated ViewFactory.

Returns
  • the caret

public Document createDefaultDocument ()

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

Returns
  • the model

public Action[] getActions ()

Fetches the set of commands that can be used on a text component that is using a model and view produced by this kit.

Returns
  • the command list

public String getContentType ()

Gets the MIME type of the data that this kit represents support for. The default is text/plain.

Returns
  • the type

public ViewFactory getViewFactory ()

Fetches a factory that is suitable for producing views of any models that are produced by this kit. The default is to have the UI produce the factory, so this method has no implementation.

Returns
  • the view factory

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

Parameters
in The stream to read from
doc The destination for the insertion.
pos The location in the document to place the content >= 0.
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

public void read (Reader in, Document doc, int pos)

Inserts content from the given stream, which will be treated as plain text.

Parameters
in The stream to read from
doc The destination for the insertion.
pos The location in the document to place the content >= 0.
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

public void write (Writer out, Document doc, int pos, int len)

Writes content from a document to the given stream as plain text.

Parameters
out The stream to write to
doc The source for the write.
pos The location in the document to fetch the content from >= 0.
len The amount to write out >= 0.
Throws
IOException on any I/O error
BadLocationException if pos is not within 0 and the length of the document.

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

Parameters
out The stream to write to
doc The source for the write.
pos The location in the document to fetch the content >= 0.
len The amount to write out >= 0.
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.