- java.lang.Object
- 
- javax.swing.text.EditorKit
- 
- javax.swing.text.DefaultEditorKit
 
 
- 
- All Implemented Interfaces:
- Serializable,- Cloneable
 - Direct Known Subclasses:
- StyledEditorKit
 
 public class DefaultEditorKit extends EditorKit 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.
 - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDefaultEditorKit.BeepActionCreates a beep.static classDefaultEditorKit.CopyActionCopies the selected region and place its contents into the system clipboard.static classDefaultEditorKit.CutActionCuts the selected region and place its contents into the system clipboard.static classDefaultEditorKit.DefaultKeyTypedActionThe action that is executed by default if a key typed event is received and there is no keymap entry.static classDefaultEditorKit.InsertBreakActionPlaces a line/paragraph break into the document.static classDefaultEditorKit.InsertContentActionPlaces content into the associated document.static classDefaultEditorKit.InsertTabActionPlaces a tab character into the document.static classDefaultEditorKit.PasteActionPastes the contents of the system clipboard into the selected region, or before the caret if nothing is selected.
 - 
Field SummaryFields Modifier and Type Field Description static StringbackwardActionName of the Action for moving the caret logically backward one position.static StringbeepActionName of the action to create a beep.static StringbeginActionName of theActionfor moving the caret to the beginning of the document.static StringbeginLineActionName of theActionfor moving the caret to the beginning of a line.static StringbeginParagraphActionName of theActionfor moving the caret to the beginning of a paragraph.static StringbeginWordActionName of theActionfor moving the caret to the beginning of a word.static StringcopyActionName of the action to copy the selected region and place the contents into the system clipboard.static StringcutActionName of the action to cut the selected region and place the contents into the system clipboard.static StringdefaultKeyTypedActionName of the action that is executed by default if a key typed event is received and there is no keymap entry.static StringdeleteNextCharActionName of the action to delete the character of content that follows the current caret position.static StringdeleteNextWordActionName of the action to delete the word that follows the beginning of the selection.static StringdeletePrevCharActionName of the action to delete the character of content that precedes the current caret position.static StringdeletePrevWordActionName of the action to delete the word that precedes the beginning of the selection.static StringdownActionName of the Action for moving the caret logically downward one position.static StringendActionName of theActionfor moving the caret to the end of the document.static StringendLineActionName of theActionfor moving the caret to the end of a line.static StringEndOfLineStringPropertyWhen reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".static StringendParagraphActionName of theActionfor moving the caret to the end of a paragraph.static StringendWordActionName of the Action for moving the caret to the end of a word.static StringforwardActionName of the Action for moving the caret logically forward one position.static StringinsertBreakActionName of the action to place a line/paragraph break into the document.static StringinsertContentActionName of the action to place content into the associated document.static StringinsertTabActionName of the action to place a tab character into the document.static StringnextWordActionName of theActionfor moving the caret to the beginning of the next word.static StringpageDownActionName of the action to page down vertically.static StringpageUpActionName of the action to page up vertically.static StringpasteActionName of the action to paste the contents of the system clipboard into the selected region, or before the caret if nothing is selected.static StringpreviousWordActionName of theActionfor moving the caret to the beginning of the previous word.static StringreadOnlyActionName of the action to set the editor into read-only mode.static StringselectAllActionName of the Action for selecting the entire documentstatic StringselectionBackwardActionName of the Action for extending the selection by moving the caret logically backward one position.static StringselectionBeginActionName of theActionfor moving the caret to the beginning of the document.static StringselectionBeginLineActionName of theActionfor moving the caret to the beginning of a line, extending the selection.static StringselectionBeginParagraphActionName of theActionfor moving the caret to the beginning of a paragraph, extending the selection.static StringselectionBeginWordActionName of theActionfor moving the caret to the beginning of a word, extending the selection.static StringselectionDownActionName of the Action for moving the caret logically downward one position, extending the selection.static StringselectionEndActionName of the Action for moving the caret to the end of the document.static StringselectionEndLineActionName of theActionfor moving the caret to the end of a line, extending the selection.static StringselectionEndParagraphActionName of theActionfor moving the caret to the end of a paragraph, extending the selection.static StringselectionEndWordActionName of the Action for moving the caret to the end of a word, extending the selection.static StringselectionForwardActionName of the Action for extending the selection by moving the caret logically forward one position.static StringselectionNextWordActionName of theActionfor moving the selection to the beginning of the next word, extending the selection.static StringselectionPreviousWordActionName of theActionfor moving the selection to the beginning of the previous word, extending the selection.static StringselectionUpActionName of the Action for moving the caret logically upward one position, extending the selection.static StringselectLineActionName of the Action for selecting a line around the caret.static StringselectParagraphActionName of the Action for selecting a paragraph around the caret.static StringselectWordActionName of the Action for selecting a word around the caret.static StringupActionName of the Action for moving the caret logically upward one position.static StringwritableActionName of the action to set the editor into writeable mode.
 - 
Constructor SummaryConstructors Constructor Description DefaultEditorKit()default constructor for DefaultEditorKit
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CaretcreateCaret()Fetches a caret that can navigate through views produced by the associated ViewFactory.DocumentcreateDefaultDocument()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.StringgetContentType()Gets the MIME type of the data that this kit represents support for.ViewFactorygetViewFactory()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.voidread(Reader in, Document doc, int pos)Inserts 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.voidwrite(Writer out, Document doc, int pos, int len)Writes content from a document to the given stream as plain text.
 
- 
- 
- 
Field Detail- 
EndOfLineStringPropertypublic 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".- See Also:
- Constant Field Values
 
 - 
insertContentActionpublic 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:
- getActions(), Constant Field Values
 
 - 
insertBreakActionpublic 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:
- getActions(), Constant Field Values
 
 - 
insertTabActionpublic 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:
- getActions(), Constant Field Values
 
 - 
deletePrevCharActionpublic static final String deletePrevCharAction Name of the action to delete the character of content that precedes the current caret position.- See Also:
- getActions(), Constant Field Values
 
 - 
deleteNextCharActionpublic static final String deleteNextCharAction Name of the action to delete the character of content that follows the current caret position.- See Also:
- getActions(), Constant Field Values
 
 - 
deleteNextWordActionpublic static final String deleteNextWordAction Name of the action to delete the word that follows the beginning of the selection.- Since:
- 1.6
- See Also:
- getActions(),- JTextComponent.getSelectionStart(), Constant Field Values
 
 - 
deletePrevWordActionpublic static final String deletePrevWordAction Name of the action to delete the word that precedes the beginning of the selection.- Since:
- 1.6
- See Also:
- getActions(),- JTextComponent.getSelectionStart(), Constant Field Values
 
 - 
readOnlyActionpublic static final String readOnlyAction Name of the action to set the editor into read-only mode.- See Also:
- getActions(), Constant Field Values
 
 - 
writableActionpublic static final String writableAction Name of the action to set the editor into writeable mode.- See Also:
- getActions(), Constant Field Values
 
 - 
cutActionpublic static final String cutAction Name of the action to cut the selected region and place the contents into the system clipboard.- See Also:
- JTextComponent.cut(),- getActions(), Constant Field Values
 
 - 
copyActionpublic static final String copyAction Name of the action to copy the selected region and place the contents into the system clipboard.- See Also:
- JTextComponent.copy(),- getActions(), Constant Field Values
 
 - 
pasteActionpublic 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.- See Also:
- JTextComponent.paste(),- getActions(), Constant Field Values
 
 - 
beepActionpublic static final String beepAction Name of the action to create a beep.- See Also:
- getActions(), Constant Field Values
 
 - 
pageUpActionpublic static final String pageUpAction Name of the action to page up vertically.- See Also:
- getActions(), Constant Field Values
 
 - 
pageDownActionpublic static final String pageDownAction Name of the action to page down vertically.- See Also:
- getActions(), Constant Field Values
 
 - 
forwardActionpublic static final String forwardAction Name of the Action for moving the caret logically forward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
backwardActionpublic static final String backwardAction Name of the Action for moving the caret logically backward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionForwardActionpublic static final String selectionForwardAction Name of the Action for extending the selection by moving the caret logically forward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionBackwardActionpublic static final String selectionBackwardAction Name of the Action for extending the selection by moving the caret logically backward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
upActionpublic static final String upAction Name of the Action for moving the caret logically upward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
downActionpublic static final String downAction Name of the Action for moving the caret logically downward one position.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionUpActionpublic static final String selectionUpAction Name of the Action for moving the caret logically upward one position, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionDownActionpublic static final String selectionDownAction Name of the Action for moving the caret logically downward one position, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
beginWordActionpublic static final String beginWordAction Name of theActionfor moving the caret to the beginning of a word.- See Also:
- getActions(), Constant Field Values
 
 - 
endWordActionpublic static final String endWordAction Name of the Action for moving the caret to the end of a word.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionBeginWordActionpublic static final String selectionBeginWordAction Name of theActionfor moving the caret to the beginning of a word, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionEndWordActionpublic static final String selectionEndWordAction Name of the Action for moving the caret to the end of a word, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
previousWordActionpublic static final String previousWordAction Name of theActionfor moving the caret to the beginning of the previous word.- See Also:
- getActions(), Constant Field Values
 
 - 
nextWordActionpublic static final String nextWordAction Name of theActionfor moving the caret to the beginning of the next word.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionPreviousWordActionpublic static final String selectionPreviousWordAction Name of theActionfor moving the selection to the beginning of the previous word, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionNextWordActionpublic static final String selectionNextWordAction Name of theActionfor moving the selection to the beginning of the next word, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
beginLineActionpublic static final String beginLineAction Name of theActionfor moving the caret to the beginning of a line.- See Also:
- getActions(), Constant Field Values
 
 - 
endLineActionpublic static final String endLineAction Name of theActionfor moving the caret to the end of a line.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionBeginLineActionpublic static final String selectionBeginLineAction Name of theActionfor moving the caret to the beginning of a line, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionEndLineActionpublic static final String selectionEndLineAction Name of theActionfor moving the caret to the end of a line, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
beginParagraphActionpublic static final String beginParagraphAction Name of theActionfor moving the caret to the beginning of a paragraph.- See Also:
- getActions(), Constant Field Values
 
 - 
endParagraphActionpublic static final String endParagraphAction Name of theActionfor moving the caret to the end of a paragraph.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionBeginParagraphActionpublic static final String selectionBeginParagraphAction Name of theActionfor moving the caret to the beginning of a paragraph, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionEndParagraphActionpublic static final String selectionEndParagraphAction Name of theActionfor moving the caret to the end of a paragraph, extending the selection.- See Also:
- getActions(), Constant Field Values
 
 - 
beginActionpublic static final String beginAction Name of theActionfor moving the caret to the beginning of the document.- See Also:
- getActions(), Constant Field Values
 
 - 
endActionpublic static final String endAction Name of theActionfor moving the caret to the end of the document.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionBeginActionpublic static final String selectionBeginAction Name of theActionfor moving the caret to the beginning of the document.- See Also:
- getActions(), Constant Field Values
 
 - 
selectionEndActionpublic static final String selectionEndAction Name of the Action for moving the caret to the end of the document.- See Also:
- getActions(), Constant Field Values
 
 - 
selectWordActionpublic static final String selectWordAction Name of the Action for selecting a word around the caret.- See Also:
- getActions(), Constant Field Values
 
 - 
selectLineActionpublic static final String selectLineAction Name of the Action for selecting a line around the caret.- See Also:
- getActions(), Constant Field Values
 
 - 
selectParagraphActionpublic static final String selectParagraphAction Name of the Action for selecting a paragraph around the caret.- See Also:
- getActions(), Constant Field Values
 
 - 
selectAllActionpublic static final String selectAllAction Name of the Action for selecting the entire document- See Also:
- getActions(), Constant Field Values
 
 - 
defaultKeyTypedActionpublic 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:
- getActions(), Constant Field Values
 
 
- 
 - 
Method Detail- 
getContentTypepublic String getContentType() Gets the MIME type of the data that this kit represents support for. The default istext/plain.- Specified by:
- getContentTypein class- EditorKit
- Returns:
- the type
 
 - 
getViewFactorypublic 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.- Specified by:
- getViewFactoryin class- EditorKit
- Returns:
- the view factory
 
 - 
getActionspublic 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.- Specified by:
- getActionsin class- EditorKit
- Returns:
- the command list
 
 - 
createCaretpublic Caret createCaret() Fetches a caret that can navigate through views produced by the associated ViewFactory.- Specified by:
- createCaretin class- EditorKit
- Returns:
- the caret
 
 - 
createDefaultDocumentpublic Document createDefaultDocument() Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.- Specified by:
- createDefaultDocumentin class- EditorKit
- Returns:
- the model
 
 - 
readpublic void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException Inserts 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.
 
 - 
readpublic void read(Reader in, Document doc, int pos) throws IOException, BadLocationException Inserts 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.
 
 
- 
 
-