javax.swing.text

Class DefaultEditorKit

Implemented Interfaces:
Cloneable, Serializable
Known Direct Subclasses:
StyledEditorKit

public class DefaultEditorKit
extends EditorKit

The default implementation of EditorKit. This EditorKit a plain text Document and several commands that together make up a basic editor, like cut / copy + paste.
See Also:
Serialized Form

Nested Class Summary

static class
DefaultEditorKit.BeepAction
Creates a beep on the PC speaker.
static class
DefaultEditorKit.CopyAction
Copies the selected content into the system clipboard.
static class
DefaultEditorKit.CutAction
Copies the selected content into the system clipboard and deletes the selection.
static class
DefaultEditorKit.DefaultKeyTypedAction
This action is executed as default action when a KEY_TYPED event is received and no keymap entry exists for that.
static class
DefaultEditorKit.InsertBreakAction
This action inserts a newline character into the document of the text component.
static class
DefaultEditorKit.InsertContentAction
Places content into the associated editor.
static class
DefaultEditorKit.InsertTabAction
Inserts a TAB character into the text editor.
static class
DefaultEditorKit.PasteAction
Copies content from the system clipboard into the editor.

Field Summary

static 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".
static String
backwardAction
The name of the Action that moves the caret one character backwards.
static String
beepAction
The name of the Action that creates a beep in the speaker.
static String
beginAction
The name of the Action that moves the caret to the beginning of the Document.
static String
beginLineAction
The name of the Action that moves the caret to the beginning of the current line.
static String
beginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph.
static String
beginWordAction
The name of the Action that moves the caret to the beginning of the current word.
static String
copyAction
The name of the Action that copies the selected content into the system clipboard.
static String
cutAction
The name of the Action that copies the selected content into the system clipboard and removes the selection.
static String
defaultKeyTypedAction
The name of the Action that is performed by default if a key is typed and there is no keymap entry.
static String
deleteNextCharAction
The name of the Action that deletes the character that follows the current caret position.
static String
deletePrevCharAction
The name of the Action that deletes the character that precedes the current caret position.
static String
downAction
The name of the Action that moves the caret one line down.
static String
endAction
The name of the Action that moves the caret to the end of the Document.
static String
endLineAction
The name of the Action that moves the caret to the end of the current line.
static String
endParagraphAction
The name of the Action that moves the caret to the end of the current paragraph.
static String
endWordAction
The name of the Action that moves the caret to the end of the current word.
static String
forwardAction
The name of the Action that moves the caret one character forward.
static String
insertBreakAction
The name of the Action that inserts a line break.
static String
insertContentAction
The name of the Action that inserts some content.
static String
insertTabAction
The name of the Action that inserts a TAB.
static String
nextWordAction
The name of the Action that moves the caret to the beginning of the next word.
static String
pageDownAction
The name of the Action that moves the caret one page down.
static String
pageUpAction
The name of the Action that moves the caret one page up.
static String
pasteAction
The name of the Action that copies content from the system clipboard into the document.
static String
previousWordAction
The name of the Action that moves the caret to the beginning of the previous word.
static String
readOnlyAction
The name of the Action that sets the editor in read only mode.
static String
selectAllAction
The name of the Action that selects the whole document.
static String
selectLineAction
The name of the Action that selects the line around the caret.
static String
selectParagraphAction
The name of the Action that selects the paragraph around the caret.
static String
selectWordAction
The name of the Action that selects the word around the caret.
static String
selectionBackwardAction
The name of the Action that moves the caret one character backwards, possibly extending the current selection.
static String
selectionBeginAction
The name of the Action that moves the caret to the beginning of the document, possibly extending the current selection.
static String
selectionBeginLineAction
The name of the Action that moves the caret to the beginning of the current line, possibly extending the current selection.
static String
selectionBeginParagraphAction
The name of the Action that moves the caret to the beginning of the current paragraph, possibly extending the current selection.
static String
selectionBeginWordAction
The name of the Action that moves the caret to the beginning of the current word, possibly extending the current selection.
static String
selectionDownAction
The name of the Action that moves the caret one line down, possibly extending the current selection.
static String
selectionEndAction
The name of the Action that moves the caret to the end of the document, possibly extending the current selection.
static String
selectionEndLineAction
The name of the Action that moves the caret to the end of the current line, possibly extending the current selection.
static String
selectionEndParagraphAction
The name of the Action that moves the caret to the end of the current paragraph, possibly extending the current selection.
static String
selectionEndWordAction
The name of the Action that moves the caret to the end of the current word, possibly extending the current selection.
static String
selectionForwardAction
The name of the Action that moves the caret one character forwards, possibly extending the current selection.
static String
selectionNextWordAction
The name of the Action that moves the caret to the beginning of the next word, possibly extending the current selection.
static String
selectionPreviousWordAction
The name of the Action that moves the caret to the beginning of the previous word, possibly extending the current selection.
static String
selectionUpAction
The name of the Action that moves the caret one line up, possibly extending the current selection.
static String
upAction
The name of the Action that moves the caret one line up.
static String
writableAction
The name of the Action that sets the editor in read-write mode.

Constructor Summary

DefaultEditorKit()
Creates a new DefaultEditorKit.

Method Summary

Caret
createCaret()
Creates the Caret for this EditorKit.
Document
createDefaultDocument()
Creates the default Document that this EditorKit supports.
Action[]
getActions()
Returns the Actions supported by this EditorKit.
String
getContentType()
Returns the content type that this EditorKit supports.
ViewFactory
getViewFactory()
Returns a ViewFactory that is able to create Views for the Elements that are used in this EditorKit's model.
void
read(InputStream in, Document document, int offset)
Reads a document of the supported content type from an InputStream into the actual Document object.
void
read(Reader in, Document document, int offset)
Reads a document of the supported content type from a Reader into the actual Document object.
void
write(OutputStream out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to an OutputStream in the supported content type format.
void
write(Writer out, Document document, int offset, int len)
Writes the Document (or a fragment of the Document) to a Writer in the supported content type format.

Methods inherited from class javax.swing.text.EditorKit

clone, createCaret, createDefaultDocument, deinstall, getActions, getContentType, getViewFactory, install, read, read, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

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".
Field Value:
"__EndOfLine__"

backwardAction

public static final String backwardAction
The name of the Action that moves the caret one character backwards.
Field Value:
"caret-backward"
See Also:
getActions()

beepAction

public static final String beepAction
The name of the Action that creates a beep in the speaker.
Field Value:
"beep"
See Also:
getActions()

beginAction

public static final String beginAction
The name of the Action that moves the caret to the beginning of the Document.
Field Value:
"caret-begin"
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.
Field Value:
"caret-begin-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.
Field Value:
"caret-begin-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.
Field Value:
"caret-begin-word"
See Also:
getActions()

copyAction

public static final String copyAction
The name of the Action that copies the selected content into the system clipboard.
Field Value:
"copy-to-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.
Field Value:
"cut-to-clipboard"
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.
Field Value:
"default-typed"
See Also:
getActions()

deleteNextCharAction

public static final String deleteNextCharAction
The name of the Action that deletes the character that follows the current caret position.
Field Value:
"delete-next"
See Also:
getActions()

deletePrevCharAction

public static final String deletePrevCharAction
The name of the Action that deletes the character that precedes the current caret position.
Field Value:
"delete-previous"
See Also:
getActions()

downAction

public static final String downAction
The name of the Action that moves the caret one line down.
Field Value:
"caret-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.
Field Value:
"caret-end"
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.
Field Value:
"caret-end-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.
Field Value:
"caret-end-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.
Field Value:
"caret-end-word"
See Also:
getActions()

forwardAction

public static final String forwardAction
The name of the Action that moves the caret one character forward.
Field Value:
"caret-forward"
See Also:
getActions()

insertBreakAction

public static final String insertBreakAction
The name of the Action that inserts a line break.
Field Value:
"insert-break"
See Also:
getActions()

insertContentAction

public static final String insertContentAction
The name of the Action that inserts some content.
Field Value:
"insert-content"
See Also:
getActions()

insertTabAction

public static final String insertTabAction
The name of the Action that inserts a TAB.
Field Value:
"insert-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.
Field Value:
"caret-next-word"
See Also:
getActions()

pageDownAction

public static final String pageDownAction
The name of the Action that moves the caret one page down.
Field Value:
"page-down"
See Also:
getActions()

pageUpAction

public static final String pageUpAction
The name of the Action that moves the caret one page up.
Field Value:
"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.
Field Value:
"paste-from-clipboard"
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.
Field Value:
"caret-previous-word"
See Also:
getActions()

readOnlyAction

public static final String readOnlyAction
The name of the Action that sets the editor in read only mode.
Field Value:
"set-read-only"
See Also:
getActions()

selectAllAction

public static final String selectAllAction
The name of the Action that selects the whole document.
Field Value:
"select-all"
See Also:
getActions()

selectLineAction

public static final String selectLineAction
The name of the Action that selects the line around the caret.
Field Value:
"select-line"
See Also:
getActions()

selectParagraphAction

public static final String selectParagraphAction
The name of the Action that selects the paragraph around the caret.
Field Value:
"select-paragraph"
See Also:
getActions()

selectWordAction

public static final String selectWordAction
The name of the Action that selects the word around the caret.
Field Value:
"select-word"
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.
Field Value:
"selection-backward"
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.
Field Value:
"selection-begin"
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.
Field Value:
"selection-begin-line"
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.
Field Value:
"selection-begin-paragraph"
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.
Field Value:
"selection-begin-word"
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.
Field Value:
"selection-down"
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.
Field Value:
"selection-end"
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.
Field Value:
"selection-end-line"
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.
Field Value:
"selection-end-paragraph"
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.
Field Value:
"selection-end-word"
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.
Field Value:
"selection-forward"
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.
Field Value:
"selection-next-word"
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.
Field Value:
"selection-previous-word"
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.
Field Value:
"selection-up"
See Also:
getActions()

upAction

public static final String upAction
The name of the Action that moves the caret one line up.
Field Value:
"caret-up"
See Also:
getActions()

writableAction

public static final String writableAction
The name of the Action that sets the editor in read-write mode.
Field Value:
"set-writable"
See Also:
getActions()

Constructor Details

DefaultEditorKit

public DefaultEditorKit()
Creates a new DefaultEditorKit.

Method Details

createCaret

public Caret createCaret()
Creates the Caret for this EditorKit. This returns a DefaultCaret in this case.
Overrides:
createCaret in interface EditorKit
Returns:
the Caret for this EditorKit

createDefaultDocument

public Document createDefaultDocument()
Creates the default Document that this EditorKit supports. This is a PlainDocument in this case.
Overrides:
createDefaultDocument in interface EditorKit
Returns:
the default Document that this EditorKit supports

getActions

public Action[] getActions()
Returns the Actions supported by this EditorKit.
Overrides:
getActions in interface 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.
Overrides:
getContentType in interface EditorKit
Returns:
the content type that this EditorKit supports

getViewFactory

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

read

public void read(InputStream in,
                 Document document,
                 int offset)
            throws BadLocationException,
                   IOException
Reads a document of the supported content type from an InputStream into the actual Document object.
Overrides:
read in interface EditorKit
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)
            throws BadLocationException,
                   IOException
Reads a document of the supported content type from a Reader into the actual Document object.
Overrides:
read in interface EditorKit
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)
            throws BadLocationException,
                   IOException
Writes the Document (or a fragment of the Document) to an OutputStream in the supported content type format.
Overrides:
write in interface EditorKit
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)
            throws BadLocationException,
                   IOException
Writes the Document (or a fragment of the Document) to a Writer in the supported content type format.
Overrides:
write in interface EditorKit
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

DefaultEditorKit.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.