javax.swing.text
Class DefaultEditorKit

java.lang.Object
  extended by javax.swing.text.EditorKit
      extended by javax.swing.text.DefaultEditorKit
All Implemented Interfaces:
Serializable, Cloneable
Direct Known 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 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 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 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 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 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 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, deinstall, install
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backwardAction

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

See Also:
getActions(), Constant Field Values

beepAction

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

See Also:
getActions(), Constant Field Values

beginAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

copyAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

deleteNextCharAction

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

See Also:
getActions(), Constant Field Values

deletePrevCharAction

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

See Also:
getActions(), Constant Field Values

downAction

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

See Also:
getActions(), Constant Field Values

endAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

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".

See Also:
Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

forwardAction

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

See Also:
getActions(), Constant Field Values

insertBreakAction

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

See Also:
getActions(), Constant Field Values

insertContentAction

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

See Also:
getActions(), Constant Field Values

insertTabAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

pageDownAction

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

See Also:
getActions(), Constant Field Values

pageUpAction

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

See Also:
getActions(), Constant Field Values

pasteAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

readOnlyAction

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

See Also:
getActions(), Constant Field Values

selectAllAction

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

See Also:
getActions(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

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(), Constant Field Values

selectLineAction

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

See Also:
getActions(), Constant Field Values

selectParagraphAction

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

See Also:
getActions(), Constant Field Values

selectWordAction

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

See Also:
getActions(), Constant Field Values

upAction

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

See Also:
getActions(), Constant Field Values

writableAction

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

See Also:
getActions(), Constant Field Values
Constructor Detail

DefaultEditorKit

public DefaultEditorKit()
Creates a new DefaultEditorKit.

Method Detail

createCaret

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

Specified by:
createCaret in class 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.

Specified by:
createDefaultDocument in class EditorKit
Returns:
the default Document that this EditorKit supports

getActions

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

Specified by:
getActions in class 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.

Specified by:
getContentType in class 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.

Specified by:
getViewFactory in class 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.

Specified by:
read in class 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.

Specified by:
read in class 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.

Specified by:
write in class 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.

Specified by:
write in class 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