- 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,EndOfLineStringProperty
is set appropriately, and when the document is written back out, theEndOfLineStringProperty
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 theEndOfLineStringProperty
has not been defined, it will use the System property when writing out the document.Note that
EndOfLineStringProperty
is set on theDocument
using theget/putProperty
methods. Subclasses may override this behavior.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and 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 Modifier and Type Field and Description static String
backwardAction
Name of the Action for moving the caret logically backward one position.static String
beepAction
Name of the action to create a beep.static String
beginAction
Name of theAction
for moving the caret to the beginning of the document.static String
beginLineAction
Name of theAction
for moving the caret to the beginning of a line.static String
beginParagraphAction
Name of theAction
for moving the caret to the beginning of a paragraph.static String
beginWordAction
Name of theAction
for moving the caret to the beginning of a word.static String
copyAction
Name of the action to copy the selected region and place the contents into the system clipboard.static String
cutAction
Name of the action to cut the selected region and place the contents into the system clipboard.static 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 String
deleteNextCharAction
Name of the action to delete the character of content that follows the current caret position.static String
deleteNextWordAction
Name of the action to delete the word that follows the beginning of the selection.static String
deletePrevCharAction
Name of the action to delete the character of content that precedes the current caret position.static String
deletePrevWordAction
Name of the action to delete the word that precedes the beginning of the selection.static String
downAction
Name of the Action for moving the caret logically downward one position.static String
endAction
Name of theAction
for moving the caret to the end of the document.static String
endLineAction
Name of theAction
for moving the caret to the end of a line.static 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 String
endParagraphAction
Name of theAction
for moving the caret to the end of a paragraph.static String
endWordAction
Name of the Action for moving the caret to the end of a word.static String
forwardAction
Name of the Action for moving the caret logically forward one position.static String
insertBreakAction
Name of the action to place a line/paragraph break into the document.static String
insertContentAction
Name of the action to place content into the associated document.static String
insertTabAction
Name of the action to place a tab character into the document.static String
nextWordAction
Name of theAction
for moving the caret to the beginning of the next word.static String
pageDownAction
Name of the action to page down vertically.static String
pageUpAction
Name of the action to page up vertically.static 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 String
previousWordAction
Name of theAction
for moving the caret to the beginning of the previous word.static String
readOnlyAction
Name of the action to set the editor into read-only mode.static String
selectAllAction
Name of the Action for selecting the entire documentstatic String
selectionBackwardAction
Name of the Action for extending the selection by moving the caret logically backward one position.static String
selectionBeginAction
Name of theAction
for moving the caret to the beginning of the document.static String
selectionBeginLineAction
Name of theAction
for moving the caret to the beginning of a line, extending the selection.static String
selectionBeginParagraphAction
Name of theAction
for moving the caret to the beginning of a paragraph, extending the selection.static String
selectionBeginWordAction
Name of theAction
for moving the caret to the beginning of a word, extending the selection.static String
selectionDownAction
Name of the Action for moving the caret logically downward one position, extending the selection.static String
selectionEndAction
Name of the Action for moving the caret to the end of the document.static String
selectionEndLineAction
Name of theAction
for moving the caret to the end of a line, extending the selection.static String
selectionEndParagraphAction
Name of theAction
for moving the caret to the end of a paragraph, extending the selection.static String
selectionEndWordAction
Name of the Action for moving the caret to the end of a word, extending the selection.static String
selectionForwardAction
Name of the Action for extending the selection by moving the caret logically forward one position.static String
selectionNextWordAction
Name of theAction
for moving the selection to the beginning of the next word, extending the selection.static String
selectionPreviousWordAction
Name of theAction
for moving the selection to the beginning of the previous word, extending the selection.static String
selectionUpAction
Name of the Action for moving the caret logically upward one position, extending the selection.static String
selectLineAction
Name of the Action for selecting a line around the caret.static String
selectParagraphAction
Name of the Action for selecting a paragraph around the caret.static String
selectWordAction
Name of the Action for selecting a word around the caret.static String
upAction
Name of the Action for moving the caret logically upward one position.static String
writableAction
Name of the action to set the editor into writeable mode.
-
Constructor Summary
Constructors Constructor and Description DefaultEditorKit()
default constructor for DefaultEditorKit
-
Method Summary
Methods Modifier and Type Method and Description 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(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.
-
-
-
Field Detail
-
EndOfLineStringProperty
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".- See Also:
- Constant Field Values
-
insertContentAction
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:
getActions()
, Constant Field Values
-
insertBreakAction
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:
getActions()
, Constant Field Values
-
insertTabAction
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:
getActions()
, Constant Field Values
-
deletePrevCharAction
public 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
-
deleteNextCharAction
public 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
-
deleteNextWordAction
public 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
-
deletePrevWordAction
public 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
-
readOnlyAction
public static final String readOnlyAction
Name of the action to set the editor into read-only mode.- See Also:
getActions()
, Constant Field Values
-
writableAction
public static final String writableAction
Name of the action to set the editor into writeable mode.- See Also:
getActions()
, Constant Field Values
-
cutAction
public static final String cutAction
Name of the action to cut the selected region and place the contents into the system clipboard.
-
copyAction
public static final String copyAction
Name of the action to copy the selected region and place the contents into the system clipboard.
-
pasteAction
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.
-
beepAction
public static final String beepAction
Name of the action to create a beep.- See Also:
getActions()
, Constant Field Values
-
pageUpAction
public static final String pageUpAction
Name of the action to page up vertically.- See Also:
getActions()
, Constant Field Values
-
pageDownAction
public static final String pageDownAction
Name of the action to page down vertically.- See Also:
getActions()
, Constant Field Values
-
forwardAction
public static final String forwardAction
Name of the Action for moving the caret logically forward one position.- See Also:
getActions()
, Constant Field Values
-
backwardAction
public static final String backwardAction
Name of the Action for moving the caret logically backward one position.- See Also:
getActions()
, Constant Field Values
-
selectionForwardAction
public 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
-
selectionBackwardAction
public 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
-
upAction
public static final String upAction
Name of the Action for moving the caret logically upward one position.- See Also:
getActions()
, Constant Field Values
-
downAction
public static final String downAction
Name of the Action for moving the caret logically downward one position.- See Also:
getActions()
, Constant Field Values
-
selectionUpAction
public 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
-
selectionDownAction
public 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
-
beginWordAction
public static final String beginWordAction
Name of theAction
for moving the caret to the beginning of a word.- See Also:
getActions()
, Constant Field Values
-
endWordAction
public static final String endWordAction
Name of the Action for moving the caret to the end of a word.- See Also:
getActions()
, Constant Field Values
-
selectionBeginWordAction
public static final String selectionBeginWordAction
Name of theAction
for moving the caret to the beginning of a word, extending the selection.- See Also:
getActions()
, Constant Field Values
-
selectionEndWordAction
public 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
-
previousWordAction
public static final String previousWordAction
Name of theAction
for moving the caret to the beginning of the previous word.- See Also:
getActions()
, Constant Field Values
-
nextWordAction
public static final String nextWordAction
Name of theAction
for moving the caret to the beginning of the next word.- See Also:
getActions()
, Constant Field Values
-
selectionPreviousWordAction
public static final String selectionPreviousWordAction
Name of theAction
for moving the selection to the beginning of the previous word, extending the selection.- See Also:
getActions()
, Constant Field Values
-
selectionNextWordAction
public static final String selectionNextWordAction
Name of theAction
for moving the selection to the beginning of the next word, extending the selection.- See Also:
getActions()
, Constant Field Values
-
beginLineAction
public static final String beginLineAction
Name of theAction
for moving the caret to the beginning of a line.- See Also:
getActions()
, Constant Field Values
-
endLineAction
public static final String endLineAction
Name of theAction
for moving the caret to the end of a line.- See Also:
getActions()
, Constant Field Values
-
selectionBeginLineAction
public static final String selectionBeginLineAction
Name of theAction
for moving the caret to the beginning of a line, extending the selection.- See Also:
getActions()
, Constant Field Values
-
selectionEndLineAction
public static final String selectionEndLineAction
Name of theAction
for moving the caret to the end of a line, extending the selection.- See Also:
getActions()
, Constant Field Values
-
beginParagraphAction
public static final String beginParagraphAction
Name of theAction
for moving the caret to the beginning of a paragraph.- See Also:
getActions()
, Constant Field Values
-
endParagraphAction
public static final String endParagraphAction
Name of theAction
for moving the caret to the end of a paragraph.- See Also:
getActions()
, Constant Field Values
-
selectionBeginParagraphAction
public static final String selectionBeginParagraphAction
Name of theAction
for moving the caret to the beginning of a paragraph, extending the selection.- See Also:
getActions()
, Constant Field Values
-
selectionEndParagraphAction
public static final String selectionEndParagraphAction
Name of theAction
for moving the caret to the end of a paragraph, extending the selection.- See Also:
getActions()
, Constant Field Values
-
beginAction
public static final String beginAction
Name of theAction
for moving the caret to the beginning of the document.- See Also:
getActions()
, Constant Field Values
-
endAction
public static final String endAction
Name of theAction
for moving the caret to the end of the document.- See Also:
getActions()
, Constant Field Values
-
selectionBeginAction
public static final String selectionBeginAction
Name of theAction
for moving the caret to the beginning of the document.- See Also:
getActions()
, Constant Field Values
-
selectionEndAction
public static final String selectionEndAction
Name of the Action for moving the caret to the end of the document.- See Also:
getActions()
, Constant Field Values
-
selectWordAction
public static final String selectWordAction
Name of the Action for selecting a word around the caret.- See Also:
getActions()
, Constant Field Values
-
selectLineAction
public static final String selectLineAction
Name of the Action for selecting a line around the caret.- See Also:
getActions()
, Constant Field Values
-
selectParagraphAction
public static final String selectParagraphAction
Name of the Action for selecting a paragraph around the caret.- See Also:
getActions()
, Constant Field Values
-
selectAllAction
public static final String selectAllAction
Name of the Action for selecting the entire document- See Also:
getActions()
, Constant Field Values
-
defaultKeyTypedAction
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:
getActions()
, Constant Field Values
-
-
Constructor Detail
-
DefaultEditorKit
public DefaultEditorKit()
default constructor for DefaultEditorKit
-
-
Method Detail
-
getContentType
public String getContentType()
Gets the MIME type of the data that this kit represents support for. The default istext/plain
.- Specified by:
getContentType
in classEditorKit
- Returns:
- the type
-
getViewFactory
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.- Specified by:
getViewFactory
in classEditorKit
- Returns:
- the view factory
-
getActions
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.- Specified by:
getActions
in classEditorKit
- Returns:
- the command list
-
createCaret
public Caret createCaret()
Fetches a caret that can navigate through views produced by the associated ViewFactory.- Specified by:
createCaret
in classEditorKit
- Returns:
- the caret
-
createDefaultDocument
public Document createDefaultDocument()
Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.- Specified by:
createDefaultDocument
in classEditorKit
- Returns:
- the model
-
read
public 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:
read
in classEditorKit
- Parameters:
in
- The stream to read fromdoc
- The destination for the insertion.pos
- The location in the document to place the content >= 0.- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
write
public 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:
write
in classEditorKit
- Parameters:
out
- The stream to write todoc
- 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 errorBadLocationException
- if pos represents an invalid location within the document.
-
read
public 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:
read
in classEditorKit
- Parameters:
in
- The stream to read fromdoc
- The destination for the insertion.pos
- The location in the document to place the content >= 0.- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
write
public 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:
write
in classEditorKit
- Parameters:
out
- The stream to write todoc
- 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 errorBadLocationException
- if pos is not within 0 and the length of the document.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/text/DefaultEditorKit.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.