java.lang.Object
javax.swing.text.EditorKit
javax.swing.text.DefaultEditorKit
- All Implemented Interfaces:
- Serializable,- Cloneable
- Direct Known Subclasses:
- StyledEditorKit
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 inDefaultEditorKit, calledEndOfLineStringProperty, 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,EndOfLineStringPropertyis set appropriately, and when the document is written back out, theEndOfLineStringPropertyis 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 theEndOfLineStringPropertyhas not been defined, it will use the System property when writing out the document.Note that EndOfLineStringPropertyis set on theDocumentusing theget/putPropertymethods. Subclasses may override this behavior.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classCreates a beep.static classCopies the selected region and place its contents into the system clipboard.static classCuts the selected region and place its contents into the system clipboard.static classThe action that is executed by default if a key typed event is received and there is no keymap entry.static classPlaces a line/paragraph break into the document.static classPlaces content into the associated document.static classPlaces a tab character into the document.static classPastes the contents of the system clipboard into the selected region, or before the caret if nothing is selected.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringName of the Action for moving the caret logically backward one position.static final StringName of the action to create a beep.static final StringName of theActionfor moving the caret to the beginning of the document.static final StringName of theActionfor moving the caret to the beginning of a line.static final StringName of theActionfor 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 StringName of theActionfor moving the caret to the beginning of a paragraph.static final StringName of theActionfor moving the caret to the beginning of a word.static final StringName of the action to copy the selected region and place the contents into the system clipboard.static final StringName of the action to cut the selected region and place the contents into the system clipboard.static final StringName of the action that is executed by default if a key typed event is received and there is no keymap entry.static final StringName of the action to delete the character of content that follows the current caret position.static final StringName of the action to delete the word that follows the beginning of the selection.static final StringName of the action to delete the character of content that precedes the current caret position.static final StringName of the action to delete the word that precedes the beginning of the selection.static final StringName of the Action for moving the caret logically downward one position.static final StringName of theActionfor moving the caret to the end of the document.static final StringName of theActionfor moving the caret to the end of a line.static final StringName of theActionfor 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 StringWhen reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".static final StringName of theActionfor moving the caret to the end of a paragraph.static final StringName of the Action for moving the caret to the end of a word.static final StringName of the Action for moving the caret logically forward one position.static final StringName of the action to place a line/paragraph break into the document.static final StringName of the action to place content into the associated document.static final StringName of the action to place a tab character into the document.static final StringName of theActionfor moving the caret to the beginning of the next word.static final StringName of the action to page down vertically.static final StringName of the action to page up vertically.static final StringName 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 StringName of theActionfor moving the caret to the beginning of the previous word.static final StringName of the action to set the editor into read-only mode.static final StringName of the Action for selecting the entire documentstatic final StringName of the Action for extending the selection by moving the caret logically backward one position.static final StringName of theActionfor moving the caret to the beginning of the document.static final StringName of theActionfor moving the caret to the beginning of a line, extending the selection.static final StringName of theActionfor moving the caret to the beginning of a paragraph, extending the selection.static final StringName of theActionfor moving the caret to the beginning of a word, extending the selection.static final StringName of the Action for moving the caret logically downward one position, extending the selection.static final StringName of the Action for moving the caret to the end of the document.static final StringName of theActionfor moving the caret to the end of a line, extending the selection.static final StringName of theActionfor moving the caret to the end of a paragraph, extending the selection.static final StringName of the Action for moving the caret to the end of a word, extending the selection.static final StringName of the Action for extending the selection by moving the caret logically forward one position.static final StringName of theActionfor moving the selection to the beginning of the next word, extending the selection.static final StringName of theActionfor moving the selection to the beginning of the previous word, extending the selection.static final StringName of the Action for moving the caret logically upward one position, extending the selection.static final StringName of the Action for selecting a line around the caret.static final StringName of the Action for selecting a paragraph around the caret.static final StringName of the Action for selecting a word around the caret.static final StringName of the Action for moving the caret logically upward one position.static final StringName of the action to set the editor into writeable mode.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionFetches a caret that can navigate through views produced by the associated ViewFactory.Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.Action[]Fetches the set of commands that can be used on a text component that is using a model and view produced by this kit.Gets the MIME type of the data that this kit represents support for.Fetches a factory that is suitable for producing views of any models that are produced by this kit.voidread(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.voidInserts content from the given stream, which will be treated as plain text.voidwrite(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.voidWrites content from a document to the given stream as plain text.
- 
Field Details- 
EndOfLineStringPropertyWhen reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".- See Also:
 
- 
insertContentActionName 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:
 
- 
insertBreakActionName 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:
 
- 
insertTabActionName 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:
 
- 
deletePrevCharActionName of the action to delete the character of content that precedes the current caret position.- See Also:
 
- 
deleteNextCharActionName of the action to delete the character of content that follows the current caret position.- See Also:
 
- 
deleteNextWordActionName of the action to delete the word that follows the beginning of the selection.- Since:
- 1.6
- See Also:
 
- 
deletePrevWordActionName of the action to delete the word that precedes the beginning of the selection.- Since:
- 1.6
- See Also:
 
- 
readOnlyActionName of the action to set the editor into read-only mode.- See Also:
 
- 
writableActionName of the action to set the editor into writeable mode.- See Also:
 
- 
cutActionName of the action to cut the selected region and place the contents into the system clipboard.- See Also:
 
- 
copyActionName of the action to copy the selected region and place the contents into the system clipboard.- See Also:
 
- 
pasteActionName of the action to paste the contents of the system clipboard into the selected region, or before the caret if nothing is selected.- See Also:
 
- 
beepActionName of the action to create a beep.- See Also:
 
- 
pageUpActionName of the action to page up vertically.- See Also:
 
- 
pageDownActionName of the action to page down vertically.- See Also:
 
- 
forwardActionName of the Action for moving the caret logically forward one position.- See Also:
 
- 
backwardActionName of the Action for moving the caret logically backward one position.- See Also:
 
- 
selectionForwardActionName of the Action for extending the selection by moving the caret logically forward one position.- See Also:
 
- 
selectionBackwardActionName of the Action for extending the selection by moving the caret logically backward one position.- See Also:
 
- 
upActionName of the Action for moving the caret logically upward one position.- See Also:
 
- 
downActionName of the Action for moving the caret logically downward one position.- See Also:
 
- 
selectionUpActionName of the Action for moving the caret logically upward one position, extending the selection.- See Also:
 
- 
selectionDownActionName of the Action for moving the caret logically downward one position, extending the selection.- See Also:
 
- 
beginWordActionName of theActionfor moving the caret to the beginning of a word.- See Also:
 
- 
endWordActionName of the Action for moving the caret to the end of a word.- See Also:
 
- 
selectionBeginWordActionName of theActionfor moving the caret to the beginning of a word, extending the selection.- See Also:
 
- 
selectionEndWordActionName of the Action for moving the caret to the end of a word, extending the selection.- See Also:
 
- 
previousWordActionName of theActionfor moving the caret to the beginning of the previous word.- See Also:
 
- 
nextWordActionName of theActionfor moving the caret to the beginning of the next word.- See Also:
 
- 
selectionPreviousWordActionName of theActionfor moving the selection to the beginning of the previous word, extending the selection.- See Also:
 
- 
selectionNextWordActionName of theActionfor moving the selection to the beginning of the next word, extending the selection.- See Also:
 
- 
beginLineActionName of theActionfor moving the caret to the beginning of a line.- See Also:
 
- 
endLineActionName of theActionfor moving the caret to the end of a line.- See Also:
 
- 
beginLineUpActionName of theActionfor 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.- See Also:
 
- 
endLineDownActionName of theActionfor 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.- See Also:
 
- 
selectionBeginLineActionName of theActionfor moving the caret to the beginning of a line, extending the selection.- See Also:
 
- 
selectionEndLineActionName of theActionfor moving the caret to the end of a line, extending the selection.- See Also:
 
- 
beginParagraphActionName of theActionfor moving the caret to the beginning of a paragraph.- See Also:
 
- 
endParagraphActionName of theActionfor moving the caret to the end of a paragraph.- See Also:
 
- 
selectionBeginParagraphActionName of theActionfor moving the caret to the beginning of a paragraph, extending the selection.- See Also:
 
- 
selectionEndParagraphActionName of theActionfor moving the caret to the end of a paragraph, extending the selection.- See Also:
 
- 
beginActionName of theActionfor moving the caret to the beginning of the document.- See Also:
 
- 
endActionName of theActionfor moving the caret to the end of the document.- See Also:
 
- 
selectionBeginActionName of theActionfor moving the caret to the beginning of the document.- See Also:
 
- 
selectionEndActionName of the Action for moving the caret to the end of the document.- See Also:
 
- 
selectWordActionName of the Action for selecting a word around the caret.- See Also:
 
- 
selectLineActionName of the Action for selecting a line around the caret.- See Also:
 
- 
selectParagraphActionName of the Action for selecting a paragraph around the caret.- See Also:
 
- 
selectAllActionName of the Action for selecting the entire document- See Also:
 
- 
defaultKeyTypedActionName of the action that is executed by default if a key typed event is received and there is no keymap entry.- See Also:
 
 
- 
- 
Constructor Details- 
DefaultEditorKitpublic DefaultEditorKit()default constructor for DefaultEditorKit
 
- 
- 
Method Details- 
getContentTypeGets the MIME type of the data that this kit represents support for. The default istext/plain.- Specified by:
- getContentTypein class- EditorKit
- Returns:
- the type
 
- 
getViewFactoryFetches 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.- Specified by:
- getViewFactoryin class- EditorKit
- Returns:
- the view factory
 
- 
getActionsFetches the set of commands that can be used on a text component that is using a model and view produced by this kit.- Specified by:
- getActionsin class- EditorKit
- Returns:
- the command list
 
- 
createCaretFetches a caret that can navigate through views produced by the associated ViewFactory.- Specified by:
- createCaretin class- EditorKit
- Returns:
- the caret
 
- 
createDefaultDocumentCreates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.- Specified by:
- createDefaultDocumentin class- EditorKit
- Returns:
- the model
 
- 
readInserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.- Specified by:
- readin class- EditorKit
- 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.
 
- 
writepublic void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException Writes content from a document to the given stream in a format appropriate for this kind of content handler.- Specified by:
- writein class- EditorKit
- 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.
 
- 
readInserts content from the given stream, which will be treated as plain text.- Specified by:
- readin class- EditorKit
- 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.
 
- 
writepublic void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException Writes content from a document to the given stream as plain text.- Specified by:
- writein class- EditorKit
- 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.
 
 
-