javax.swing.text

Class DefaultEditorKit

public class DefaultEditorKit extends EditorKit

The default implementation of {@link EditorKit}. This EditorKit a plain text Document and several commands that together make up a basic editor, like cut / copy + paste.
Nested Class Summary
static classDefaultEditorKit.BeepAction
Creates a beep on the PC speaker.
static classDefaultEditorKit.CopyAction
Copies the selected content into the system clipboard.
static classDefaultEditorKit.CutAction
Copies the selected content into the system clipboard and deletes the selection.
static classDefaultEditorKit.DefaultKeyTypedAction
This action is executed as default action when a KEY_TYPED event is received and no keymap entry exists for that.
static classDefaultEditorKit.InsertBreakAction
This action inserts a newline character into the document of the text component.
static classDefaultEditorKit.InsertContentAction
Places content into the associated editor.
static classDefaultEditorKit.InsertTabAction
Inserts a TAB character into the text editor.
static classDefaultEditorKit.PasteAction
Copies content from the system clipboard into the editor.
Field Summary
static StringbackwardAction
The name of the Action that moves the caret one character backwards.
static StringbeepAction
The name of the Action that creates a beep in the speaker.
static StringbeginAction
The name of the Action that moves the caret to the beginning of the Document.
static StringbeginLineAction
The name of the Action that moves the caret to the beginning of the current line.
static StringbeginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph.
static StringbeginWordAction
The name of the Action that moves the caret to the beginning of the current word.
static StringcopyAction
The name of the Action that copies the selected content into the system clipboard.
static StringcutAction
The name of the Action that copies the selected content into the system clipboard and removes the selection.
static StringdefaultKeyTypedAction
The name of the Action that is performed by default if a key is typed and there is no keymap entry.
static StringdeleteNextCharAction
The name of the Action that deletes the character that follows the current caret position.
static StringdeletePrevCharAction
The name of the Action that deletes the character that precedes the current caret position.
static StringdownAction
The name of the Action that moves the caret one line down.
static StringendAction
The name of the Action that moves the caret to the end of the Document.
static StringendLineAction
The name of the Action that moves the caret to the end of the current line.
static StringendParagraphAction
The name of the Action that moves the caret to the end of the current paragraph.
static StringendWordAction
The name of the Action that moves the caret to the end of the current word.
static StringEndOfLineStringProperty
When a document is read and an CRLF is encountered, then we add a property with this name and a value of "\r\n".
static StringforwardAction
The name of the Action that moves the caret one character forward.
static StringinsertBreakAction
The name of the Action that inserts a line break.
static StringinsertContentAction
The name of the Action that inserts some content.
static StringinsertTabAction
The name of the Action that inserts a TAB.
static StringnextWordAction
The name of the Action that moves the caret to the beginning of the next word.
static StringpageDownAction
The name of the Action that moves the caret one page down.
static StringpageUpAction
The name of the Action that moves the caret one page up.
static StringpasteAction
The name of the Action that copies content from the system clipboard into the document.
static StringpreviousWordAction
The name of the Action that moves the caret to the beginning of the previous word.
static StringreadOnlyAction
The name of the Action that sets the editor in read only mode.
static StringselectAllAction
The name of the Action that selects the whole document.
static StringselectionBackwardAction
The name of the Action that moves the caret one character backwards, possibly extending the current selection.
static StringselectionBeginAction
The name of the Action that moves the caret to the beginning of the document, possibly extending the current selection.
static StringselectionBeginLineAction
The name of the Action that moves the caret to the beginning of the current line, possibly extending the current selection.
static StringselectionBeginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph, possibly extending the current selection.
static StringselectionBeginWordAction
The name of the Action that moves the caret to the beginning of the current word, possibly extending the current selection.
static StringselectionDownAction
The name of the Action that moves the caret one line down, possibly extending the current selection.
static StringselectionEndAction
The name of the Action that moves the caret to the end of the document, possibly extending the current selection.
static StringselectionEndLineAction
The name of the Action that moves the caret to the end of the current line, possibly extending the current selection.
static StringselectionEndParagraphAction
The name of the Action that moves the caret to the end of the current paragraph, possibly extending the current selection.
static StringselectionEndWordAction
The name of the Action that moves the caret to the end of the current word, possibly extending the current selection.
static StringselectionForwardAction
The name of the Action that moves the caret one character forwards, possibly extending the current selection.
static StringselectionNextWordAction
The name of the Action that moves the caret to the beginning of the next word, possibly extending the current selection.
static StringselectionPreviousWordAction
The name of the Action that moves the caret to the beginning of the previous word, possibly extending the current selection.
static StringselectionUpAction
The name of the Action that moves the caret one line up, possibly extending the current selection.
static StringselectLineAction
The name of the Action that selects the line around the caret.
static StringselectParagraphAction
The name of the Action that selects the paragraph around the caret.
static StringselectWordAction
The name of the Action that selects the word around the caret.
static StringupAction
The name of the Action that moves the caret one line up.
static StringwritableAction
The name of the Action that sets the editor in read-write mode.
Constructor Summary
DefaultEditorKit()
Creates a new DefaultEditorKit.
Method Summary
CaretcreateCaret()
Creates the Caret for this EditorKit.
DocumentcreateDefaultDocument()
Creates the default {@link Document} that this EditorKit supports.
Action[]getActions()
Returns the Actions supported by this EditorKit.
StringgetContentType()
Returns the content type that this EditorKit supports.
ViewFactorygetViewFactory()
Returns a {@link ViewFactory} that is able to create {@link View}s for the Elements that are used in this EditorKit's model.
voidread(InputStream in, Document document, int offset)
Reads a document of the supported content type from an {@link InputStream} into the actual {@link Document} object.
voidread(Reader in, Document document, int offset)
Reads a document of the supported content type from a {@link Reader} into the actual {@link Document} object.
voidwrite(OutputStream out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to an {@link OutputStream} in the supported content type format.
voidwrite(Writer out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to a {@link Writer} in the supported content type format.

Field Detail

backwardAction

public static final String backwardAction
The name of the Action that moves the caret one character backwards.

See Also: getActions

beepAction

public static final String beepAction
The name of the Action that creates a beep in the speaker.

See Also: getActions

beginAction

public static final String beginAction
The name of the Action that moves the caret to the beginning of the Document.

See Also: getActions

beginLineAction

public static final String beginLineAction
The name of the Action that moves the caret to the beginning of the current line.

See Also: getActions

beginParagraphAction

public static final String beginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph.

See Also: getActions

beginWordAction

public static final String beginWordAction
The name of the Action that moves the caret to the beginning of the current word.

See Also: getActions

copyAction

public static final String copyAction
The name of the Action that copies the selected content into the system clipboard.

See Also: getActions

cutAction

public static final String cutAction
The name of the Action that copies the selected content into the system clipboard and removes the selection.

See Also: getActions

defaultKeyTypedAction

public static final String defaultKeyTypedAction
The name of the Action that is performed by default if a key is typed and there is no keymap entry.

See Also: getActions

deleteNextCharAction

public static final String deleteNextCharAction
The name of the Action that deletes the character that follows the current caret position.

See Also: getActions

deletePrevCharAction

public static final String deletePrevCharAction
The name of the Action that deletes the character that precedes the current caret position.

See Also: getActions

downAction

public static final String downAction
The name of the Action that moves the caret one line down.

See Also: getActions

endAction

public static final String endAction
The name of the Action that moves the caret to the end of the Document.

See Also: getActions

endLineAction

public static final String endLineAction
The name of the Action that moves the caret to the end of the current line.

See Also: getActions

endParagraphAction

public static final String endParagraphAction
The name of the Action that moves the caret to the end of the current paragraph.

See Also: getActions

endWordAction

public static final String endWordAction
The name of the Action that moves the caret to the end of the current word.

See Also: getActions

EndOfLineStringProperty

public static final String EndOfLineStringProperty
When a document is read and an CRLF is encountered, then we add a property with this name and a value of "\r\n".

forwardAction

public static final String forwardAction
The name of the Action that moves the caret one character forward.

See Also: getActions

insertBreakAction

public static final String insertBreakAction
The name of the Action that inserts a line break.

See Also: getActions

insertContentAction

public static final String insertContentAction
The name of the Action that inserts some content.

See Also: getActions

insertTabAction

public static final String insertTabAction
The name of the Action that inserts a TAB.

See Also: getActions

nextWordAction

public static final String nextWordAction
The name of the Action that moves the caret to the beginning of the next word.

See Also: getActions

pageDownAction

public static final String pageDownAction
The name of the Action that moves the caret one page down.

See Also: getActions

pageUpAction

public static final String pageUpAction
The name of the Action that moves the caret one page up.

See Also: getActions

pasteAction

public static final String pasteAction
The name of the Action that copies content from the system clipboard into the document.

See Also: getActions

previousWordAction

public static final String previousWordAction
The name of the Action that moves the caret to the beginning of the previous word.

See Also: getActions

readOnlyAction

public static final String readOnlyAction
The name of the Action that sets the editor in read only mode.

See Also: getActions

selectAllAction

public static final String selectAllAction
The name of the Action that selects the whole document.

See Also: getActions

selectionBackwardAction

public static final String selectionBackwardAction
The name of the Action that moves the caret one character backwards, possibly extending the current selection.

See Also: getActions

selectionBeginAction

public static final String selectionBeginAction
The name of the Action that moves the caret to the beginning of the document, possibly extending the current selection.

See Also: getActions

selectionBeginLineAction

public static final String selectionBeginLineAction
The name of the Action that moves the caret to the beginning of the current line, possibly extending the current selection.

See Also: getActions

selectionBeginParagraphAction

public static final String selectionBeginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph, possibly extending the current selection.

See Also: getActions

selectionBeginWordAction

public static final String selectionBeginWordAction
The name of the Action that moves the caret to the beginning of the current word, possibly extending the current selection.

See Also: getActions

selectionDownAction

public static final String selectionDownAction
The name of the Action that moves the caret one line down, possibly extending the current selection.

See Also: getActions

selectionEndAction

public static final String selectionEndAction
The name of the Action that moves the caret to the end of the document, possibly extending the current selection.

See Also: getActions

selectionEndLineAction

public static final String selectionEndLineAction
The name of the Action that moves the caret to the end of the current line, possibly extending the current selection.

See Also: getActions

selectionEndParagraphAction

public static final String selectionEndParagraphAction
The name of the Action that moves the caret to the end of the current paragraph, possibly extending the current selection.

See Also: getActions

selectionEndWordAction

public static final String selectionEndWordAction
The name of the Action that moves the caret to the end of the current word, possibly extending the current selection.

See Also: getActions

selectionForwardAction

public static final String selectionForwardAction
The name of the Action that moves the caret one character forwards, possibly extending the current selection.

See Also: getActions

selectionNextWordAction

public static final String selectionNextWordAction
The name of the Action that moves the caret to the beginning of the next word, possibly extending the current selection.

See Also: getActions

selectionPreviousWordAction

public static final String selectionPreviousWordAction
The name of the Action that moves the caret to the beginning of the previous word, possibly extending the current selection.

See Also: getActions

selectionUpAction

public static final String selectionUpAction
The name of the Action that moves the caret one line up, possibly extending the current selection.

See Also: getActions

selectLineAction

public static final String selectLineAction
The name of the Action that selects the line around the caret.

See Also: getActions

selectParagraphAction

public static final String selectParagraphAction
The name of the Action that selects the paragraph around the caret.

See Also: getActions

selectWordAction

public static final String selectWordAction
The name of the Action that selects the word around the caret.

See Also: getActions

upAction

public static final String upAction
The name of the Action that moves the caret one line up.

See Also: getActions

writableAction

public static final String writableAction
The name of the Action that sets the editor in read-write mode.

See Also: getActions

Constructor Detail

DefaultEditorKit

public DefaultEditorKit()
Creates a new DefaultEditorKit.

Method Detail

createCaret

public Caret createCaret()
Creates the Caret for this EditorKit. This returns a {@link DefaultCaret} in this case.

Returns: the Caret for this EditorKit

createDefaultDocument

public Document createDefaultDocument()
Creates the default {@link Document} that this EditorKit supports. This is a {@link PlainDocument} in this case.

Returns: the default {@link Document} that this EditorKit supports

getActions

public Action[] getActions()
Returns the Actions supported by this EditorKit.

Returns: the Actions supported by this EditorKit

getContentType

public String getContentType()
Returns the content type that this EditorKit supports. The DefaultEditorKit supports the content type text/plain.

Returns: the content type that this EditorKit supports

getViewFactory

public ViewFactory getViewFactory()
Returns a {@link ViewFactory} that is able to create {@link View}s for the Elements that are used in this EditorKit's model. This returns null which lets the UI of the text component supply Views.

Returns: a {@link ViewFactory} that is able to create {@link View}s for the Elements that are used in this EditorKit's model

read

public void read(InputStream in, Document document, int offset)
Reads a document of the supported content type from an {@link InputStream} into the actual {@link Document} object.

Parameters: in the stream from which to read the document document the document model into which the content is read offset the offset inside to document where the content is inserted

Throws: BadLocationException if offset is an invalid location inside document IOException if something goes wrong while reading from in

read

public void read(Reader in, Document document, int offset)
Reads a document of the supported content type from a {@link Reader} into the actual {@link Document} object.

Parameters: in the reader from which to read the document document the document model into which the content is read offset the offset inside to document where the content is inserted

Throws: BadLocationException if offset is an invalid location inside document IOException if something goes wrong while reading from in

write

public void write(OutputStream out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to an {@link OutputStream} in the supported content type format.

Parameters: out the stream to write to document the document that should be written out offset the beginning offset from where to write len the length of the fragment to write

Throws: BadLocationException if offset or offset + lenis an invalid location inside document IOException if something goes wrong while writing to out

write

public void write(Writer out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to a {@link Writer} in the supported content type format.

Parameters: out the writer to write to document the document that should be written out offset the beginning offset from where to write len the length of the fragment to write

Throws: BadLocationException if offset is an invalid location inside document. IOException if something goes wrong while writing to out