javax.swing.text
Class DefaultEditorKit

java.lang.Object
  |
  +--javax.swing.text.EditorKit
        |
        +--javax.swing.text.DefaultEditorKit
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
javax.swing.JEditorPane.PlainEditorKit, StyledEditorKit

public class DefaultEditorKit
extends EditorKit

Safe: 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 in DefaultEditorKit, called EndOfLineStringProperty, 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, the EndOfLineStringProperty 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 the EndOfLineStringProperty has not been defined, it will use the System property when writing out the document.

Note that EndOfLineStringProperty is set on the Document using the get/setProperty methods. Subclasses may override this behavior.

Version:
1.62 12/03/01
Author:
Timothy Prinzing
See Also:
Serialized Form

Field Summary
static String backwardAction
          Suppressed: Name of the Action for moving the caret logically backward one position.
static String beepAction
          Suppressed: Name of the action to create a beep.
static String beginAction
          Suppressed: Name of the Action for moving the caret to the beginning of the document.
static String beginLineAction
          Suppressed: Name of the Action for moving the caret to the beginning of a line.
static String beginParagraphAction
          Suppressed: Name of the Action for moving the caret to the beginning of a paragraph.
static String beginWordAction
          Suppressed: Name of the Action for moving the caret to the beginning of a word.
static String copyAction
          Suppressed: Name of the action to copy the selected region and place the contents into the system clipboard.
static String cutAction
          Suppressed: Name of the action to cut the selected region and place the contents into the system clipboard.
private static Action[] defaultActions
           
static String defaultKeyTypedAction
          Suppressed: 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
          Suppressed: Name of the action to delete the character of content that follows the current caret position.
static String deletePrevCharAction
          Suppressed: Name of the action to delete the character of content that precedes the current caret position.
static String downAction
          Suppressed: Name of the Action for moving the caret logically downward one position.
static String endAction
          Suppressed: Name of the Action for moving the caret to the end of the document.
static String endLineAction
          Suppressed: Name of the Action for moving the caret to the end of a line.
static String EndOfLineStringProperty
          Suppressed: 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
          Suppressed: Name of the Action for moving the caret to the end of a paragraph.
static String endWordAction
          Suppressed: Name of the Action for moving the caret to the end of a word.
static String forwardAction
          Suppressed: Name of the Action for moving the caret logically forward one position.
static String insertBreakAction
          Suppressed: Name of the action to place a line/paragraph break into the document.
static String insertContentAction
          Suppressed: Name of the action to place content into the associated document.
static String insertTabAction
          Suppressed: Name of the action to place a tab character into the document.
static String nextWordAction
          Suppressed: Name of the Action for moving the caret to the beginning of the next word.
static String pageDownAction
          Suppressed: Name of the action to page down vertically.
static String pageUpAction
          Suppressed: Name of the action to page up vertically.
static String pasteAction
          Suppressed: 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
          Suppressed: Name of the Action for moving the caret to the beginning of the previous word.
static String readOnlyAction
          Suppressed: Name of the action to set the editor into read-only mode.
static String selectAllAction
          Suppressed: Name of the Action for selecting the entire document
static String selectionBackwardAction
          Suppressed: Name of the Action for extending the selection by moving the caret logically backward one position.
static String selectionBeginAction
          Suppressed: Name of the Action for moving the caret to the beginning of the document.
static String selectionBeginLineAction
          Suppressed: Name of the Action for moving the caret to the beginning of a line, extending the selection.
static String selectionBeginParagraphAction
          Suppressed: Name of the Action for moving the caret to the beginning of a paragraph, extending the selection.
static String selectionBeginWordAction
          Suppressed: Name of the Action for moving the caret to the beginning of a word, extending the selection.
static String selectionDownAction
          Suppressed: Name of the Action for moving the caret logically downward one position, extending the selection.
static String selectionEndAction
          Suppressed: Name of the Action for moving the caret to the end of the document.
static String selectionEndLineAction
          Suppressed: Name of the Action for moving the caret to the end of a line, extending the selection.
static String selectionEndParagraphAction
          Suppressed: Name of the Action for moving the caret to the end of a paragraph, extending the selection.
static String selectionEndWordAction
          Suppressed: Name of the Action for moving the caret to the end of a word, extending the selection.
static String selectionForwardAction
          Suppressed: Name of the Action for extending the selection by moving the caret logically forward one position.
static String selectionNextWordAction
          Suppressed: Name of the Action for moving the selection to the beginning of the next word, extending the selection.
(package private) static String selectionPageDownAction
          Name of the action to page down vertically, and move the selection.
(package private) static String selectionPageLeftAction
          Name of the action to page left horizontally, and move the selection.
(package private) static String selectionPageRightAction
          Name of the action to page right horizontally, and move the selection.
(package private) static String selectionPageUpAction
          Name of the action to page up vertically, and move the selection.
static String selectionPreviousWordAction
          Suppressed: Name of the Action for moving the selection to the beginning of the previous word, extending the selection.
static String selectionUpAction
          Suppressed: Name of the Action for moving the caret logically upward one position, extending the selection.
static String selectLineAction
          Suppressed: Name of the Action for selecting a line around the caret.
static String selectParagraphAction
          Suppressed: Name of the Action for selecting a paragraph around the caret.
static String selectWordAction
          Suppressed: Name of the Action for selecting a word around the caret.
(package private) static String toggleComponentOrientationAction
          Name of the Action for toggling the component's orientation.
(package private) static String unselectAction
          Name of the Action for removing selection
static String upAction
          Suppressed: Name of the Action for moving the caret logically upward one position.
static String writableAction
          Suppressed: Name of the action to set the editor into writeable mode.
 
Constructor Summary
DefaultEditorKit()
          Enabled: default constructor for DefaultEditorKit
 
Method Summary
 Caret createCaret()
          Enabled: Fetches a caret that can navigate through views produced by the associated ViewFactory.
 Document createDefaultDocument()
          Enabled: Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.
 Action[] getActions()
          Suppressed: 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()
          Enabled: Gets the MIME type of the data that this kit represents support for.
(package private)  MutableAttributeSet getInputAttributes()
          Gets the input attributes for the pane.
 ViewFactory getViewFactory()
          Enabled: 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)
          Enabled: 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)
          Enabled: Inserts content from the given stream, which will be treated as plain text.
 void write(OutputStream out, Document doc, int pos, int len)
          Enabled: 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)
          Enabled: Writes content from a document to the given stream as plain text.
 
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

EndOfLineStringProperty

public static final String EndOfLineStringProperty
Suppressed: When reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".


insertContentAction

public static final String insertContentAction
Suppressed: 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()

insertBreakAction

public static final String insertBreakAction
Suppressed: 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()

insertTabAction

public static final String insertTabAction
Suppressed: 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()

deletePrevCharAction

public static final String deletePrevCharAction
Suppressed: Name of the action to delete the character of content that precedes the current caret position.

See Also:
getActions()

deleteNextCharAction

public static final String deleteNextCharAction
Suppressed: Name of the action to delete the character of content that follows the current caret position.

See Also:
getActions()

readOnlyAction

public static final String readOnlyAction
Suppressed: Name of the action to set the editor into read-only mode.

See Also:
getActions()

writableAction

public static final String writableAction
Suppressed: Name of the action to set the editor into writeable mode.

See Also:
getActions()

cutAction

public static final String cutAction
Suppressed: Name of the action to cut the selected region and place the contents into the system clipboard.

See Also:
JTextComponent.cut(), getActions()

copyAction

public static final String copyAction
Suppressed: Name of the action to copy the selected region and place the contents into the system clipboard.

See Also:
JTextComponent.copy(), getActions()

pasteAction

public static final String pasteAction
Suppressed: 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()

beepAction

public static final String beepAction
Suppressed: Name of the action to create a beep.

See Also:
getActions()

pageUpAction

public static final String pageUpAction
Suppressed: Name of the action to page up vertically.

See Also:
getActions()

pageDownAction

public static final String pageDownAction
Suppressed: Name of the action to page down vertically.

See Also:
getActions()

selectionPageUpAction

static final String selectionPageUpAction
Name of the action to page up vertically, and move the selection.

See Also:
getActions()

selectionPageDownAction

static final String selectionPageDownAction
Name of the action to page down vertically, and move the selection.

See Also:
getActions()

selectionPageLeftAction

static final String selectionPageLeftAction
Name of the action to page left horizontally, and move the selection.

See Also:
getActions()

selectionPageRightAction

static final String selectionPageRightAction
Name of the action to page right horizontally, and move the selection.

See Also:
getActions()

forwardAction

public static final String forwardAction
Suppressed: Name of the Action for moving the caret logically forward one position.

See Also:
getActions()

backwardAction

public static final String backwardAction
Suppressed: Name of the Action for moving the caret logically backward one position.

See Also:
getActions()

selectionForwardAction

public static final String selectionForwardAction
Suppressed: Name of the Action for extending the selection by moving the caret logically forward one position.

See Also:
getActions()

selectionBackwardAction

public static final String selectionBackwardAction
Suppressed: Name of the Action for extending the selection by moving the caret logically backward one position.

See Also:
getActions()

upAction

public static final String upAction
Suppressed: Name of the Action for moving the caret logically upward one position.

See Also:
getActions()

downAction

public static final String downAction
Suppressed: Name of the Action for moving the caret logically downward one position.

See Also:
getActions()

selectionUpAction

public static final String selectionUpAction
Suppressed: Name of the Action for moving the caret logically upward one position, extending the selection.

See Also:
getActions()

selectionDownAction

public static final String selectionDownAction
Suppressed: Name of the Action for moving the caret logically downward one position, extending the selection.

See Also:
getActions()

beginWordAction

public static final String beginWordAction
Suppressed: Name of the Action for moving the caret to the beginning of a word.

See Also:
getActions()

endWordAction

public static final String endWordAction
Suppressed: Name of the Action for moving the caret to the end of a word.

See Also:
getActions()

selectionBeginWordAction

public static final String selectionBeginWordAction
Suppressed: Name of the Action for moving the caret to the beginning of a word, extending the selection.

See Also:
getActions()

selectionEndWordAction

public static final String selectionEndWordAction
Suppressed: Name of the Action for moving the caret to the end of a word, extending the selection.

See Also:
getActions()

previousWordAction

public static final String previousWordAction
Suppressed: Name of the Action for moving the caret to the beginning of the previous word.

See Also:
getActions()

nextWordAction

public static final String nextWordAction
Suppressed: Name of the Action for moving the caret to the beginning of the next word.

See Also:
getActions()

selectionPreviousWordAction

public static final String selectionPreviousWordAction
Suppressed: Name of the Action for moving the selection to the beginning of the previous word, extending the selection.

See Also:
getActions()

selectionNextWordAction

public static final String selectionNextWordAction
Suppressed: Name of the Action for moving the selection to the beginning of the next word, extending the selection.

See Also:
getActions()

beginLineAction

public static final String beginLineAction
Suppressed: Name of the Action for moving the caret to the beginning of a line.

See Also:
getActions()

endLineAction

public static final String endLineAction
Suppressed: Name of the Action for moving the caret to the end of a line.

See Also:
getActions()

selectionBeginLineAction

public static final String selectionBeginLineAction
Suppressed: Name of the Action for moving the caret to the beginning of a line, extending the selection.

See Also:
getActions()

selectionEndLineAction

public static final String selectionEndLineAction
Suppressed: Name of the Action for moving the caret to the end of a line, extending the selection.

See Also:
getActions()

beginParagraphAction

public static final String beginParagraphAction
Suppressed: Name of the Action for moving the caret to the beginning of a paragraph.

See Also:
getActions()

endParagraphAction

public static final String endParagraphAction
Suppressed: Name of the Action for moving the caret to the end of a paragraph.

See Also:
getActions()

selectionBeginParagraphAction

public static final String selectionBeginParagraphAction
Suppressed: Name of the Action for moving the caret to the beginning of a paragraph, extending the selection.

See Also:
getActions()

selectionEndParagraphAction

public static final String selectionEndParagraphAction
Suppressed: Name of the Action for moving the caret to the end of a paragraph, extending the selection.

See Also:
getActions()

beginAction

public static final String beginAction
Suppressed: Name of the Action for moving the caret to the beginning of the document.

See Also:
getActions()

endAction

public static final String endAction
Suppressed: Name of the Action for moving the caret to the end of the document.

See Also:
getActions()

selectionBeginAction

public static final String selectionBeginAction
Suppressed: Name of the Action for moving the caret to the beginning of the document.

See Also:
getActions()

selectionEndAction

public static final String selectionEndAction
Suppressed: Name of the Action for moving the caret to the end of the document.

See Also:
getActions()

selectWordAction

public static final String selectWordAction
Suppressed: Name of the Action for selecting a word around the caret.

See Also:
getActions()

selectLineAction

public static final String selectLineAction
Suppressed: Name of the Action for selecting a line around the caret.

See Also:
getActions()

selectParagraphAction

public static final String selectParagraphAction
Suppressed: Name of the Action for selecting a paragraph around the caret.

See Also:
getActions()

selectAllAction

public static final String selectAllAction
Suppressed: Name of the Action for selecting the entire document

See Also:
getActions()

unselectAction

static final String unselectAction
Name of the Action for removing selection

See Also:
getActions()

toggleComponentOrientationAction

static final String toggleComponentOrientationAction
Name of the Action for toggling the component's orientation.

See Also:
getActions()

defaultKeyTypedAction

public static final String defaultKeyTypedAction
Suppressed: 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()

defaultActions

private static final Action[] defaultActions
Constructor Detail

DefaultEditorKit

public DefaultEditorKit()
Enabled: default constructor for DefaultEditorKit

Method Detail

getContentType

public String getContentType()
Enabled: Gets the MIME type of the data that this kit represents support for. The default is text/plain.

Specified by:
getContentType in class EditorKit
Returns:
the type

getViewFactory

public ViewFactory getViewFactory()
Enabled: 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 class EditorKit
Returns:
the view factory

getActions

public Action[] getActions()
Suppressed: 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 class EditorKit
Returns:
the command list

createCaret

public Caret createCaret()
Enabled: Fetches a caret that can navigate through views produced by the associated ViewFactory.

Specified by:
createCaret in class EditorKit
Returns:
the caret

createDefaultDocument

public Document createDefaultDocument()
Enabled: Creates an uninitialized text storage model (PlainDocument) that is appropriate for this type of editor.

Specified by:
createDefaultDocument in class EditorKit
Returns:
the model

read

public void read(InputStream in,
                 Document doc,
                 int pos)
          throws IOException,
                 BadLocationException
Enabled: 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 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.
IOException
BadLocationException

write

public void write(OutputStream out,
                  Document doc,
                  int pos,
                  int len)
           throws IOException,
                  BadLocationException
Enabled: Writes content from a document to the given stream in a format appropriate for this kind of content handler.

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

getInputAttributes

MutableAttributeSet getInputAttributes()
Gets the input attributes for the pane. This method exists for the benefit of StyledEditorKit so that the read method will pick up the correct attributes to apply to inserted text. This class's implementation simply returns null.

Returns:
null

read

public void read(Reader in,
                 Document doc,
                 int pos)
          throws IOException,
                 BadLocationException
Enabled: Inserts content from the given stream, which will be treated as plain text.

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

write

public void write(Writer out,
                  Document doc,
                  int pos,
                  int len)
           throws IOException,
                  BadLocationException
Enabled: Writes content from a document to the given stream as plain text.

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


comments?