javax.swing.text
public class DefaultEditorKit extends EditorKit
EditorKit
. This EditorKit
a plain text Document
and several commands that together
make up a basic editor, like cut / copy + paste.Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
DefaultEditorKit()
Creates a new
DefaultEditorKit . |
Modifier and Type | Method and Description |
---|---|
Caret |
createCaret()
Creates the
Caret for this EditorKit . |
Document |
createDefaultDocument()
Creates the default
Document that this EditorKit
supports. |
Action[] |
getActions()
Returns the
Action s supported by this EditorKit . |
String |
getContentType()
Returns the content type that this
EditorKit supports. |
ViewFactory |
getViewFactory()
Returns a
ViewFactory that is able to create View s for
the Element s 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)
|
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. |
public static final String backwardAction
Action
that moves the caret one character
backwards.getActions()
,
Constant Field Valuespublic static final String beepAction
Action
that creates a beep in the speaker.getActions()
,
Constant Field Valuespublic static final String beginAction
Action
that moves the caret to the beginning
of the Document
.getActions()
,
Constant Field Valuespublic static final String beginLineAction
Action
that moves the caret to the beginning
of the current line.getActions()
,
Constant Field Valuespublic static final String beginParagraphAction
Action
that moves the caret to the beginning
of the current paragraph.getActions()
,
Constant Field Valuespublic static final String beginWordAction
Action
that moves the caret to the beginning
of the current word.getActions()
,
Constant Field Valuespublic static final String copyAction
Action
that copies the selected content
into the system clipboard.getActions()
,
Constant Field Valuespublic static final String cutAction
Action
that copies the selected content
into the system clipboard and removes the selection.getActions()
,
Constant Field Valuespublic static final String defaultKeyTypedAction
Action
that is performed by default if
a key is typed and there is no keymap entry.getActions()
,
Constant Field Valuespublic static final String deleteNextCharAction
Action
that deletes the character that
follows the current caret position.getActions()
,
Constant Field Valuespublic static final String deletePrevCharAction
Action
that deletes the character that
precedes the current caret position.getActions()
,
Constant Field Valuespublic static final String downAction
Action
that moves the caret one line down.getActions()
,
Constant Field Valuespublic static final String endAction
Action
that moves the caret to the end
of the Document
.getActions()
,
Constant Field Valuespublic static final String endLineAction
Action
that moves the caret to the end
of the current line.getActions()
,
Constant Field Valuespublic static final String EndOfLineStringProperty
public static final String endParagraphAction
Action
that moves the caret to the end
of the current paragraph.getActions()
,
Constant Field Valuespublic static final String endWordAction
Action
that moves the caret to the end
of the current word.getActions()
,
Constant Field Valuespublic static final String forwardAction
Action
that moves the caret one character
forward.getActions()
,
Constant Field Valuespublic static final String insertBreakAction
Action
that inserts a line break.getActions()
,
Constant Field Valuespublic static final String insertContentAction
Action
that inserts some content.getActions()
,
Constant Field Valuespublic static final String insertTabAction
Action
that inserts a TAB.getActions()
,
Constant Field Valuespublic static final String nextWordAction
Action
that moves the caret to the beginning
of the next word.getActions()
,
Constant Field Valuespublic static final String pageDownAction
Action
that moves the caret one page down.getActions()
,
Constant Field Valuespublic static final String pageUpAction
Action
that moves the caret one page up.getActions()
,
Constant Field Valuespublic static final String pasteAction
Action
that copies content from the system
clipboard into the document.getActions()
,
Constant Field Valuespublic static final String previousWordAction
Action
that moves the caret to the beginning
of the previous word.getActions()
,
Constant Field Valuespublic static final String readOnlyAction
Action
that sets the editor in read only
mode.getActions()
,
Constant Field Valuespublic static final String selectAllAction
Action
that selects the whole document.getActions()
,
Constant Field Valuespublic static final String selectionBackwardAction
Action
that moves the caret one character
backwards, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionBeginAction
Action
that moves the caret to the beginning
of the document, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionBeginLineAction
Action
that moves the caret to the beginning
of the current line, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionBeginParagraphAction
Action
that moves the caret to the beginning
of the current paragraph, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionBeginWordAction
Action
that moves the caret to the beginning
of the current word, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionDownAction
Action
that moves the caret one line down,
possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionEndAction
Action
that moves the caret to the end
of the document, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionEndLineAction
Action
that moves the caret to the end
of the current line, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionEndParagraphAction
Action
that moves the caret to the end
of the current paragraph, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionEndWordAction
Action
that moves the caret to the end
of the current word, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionForwardAction
Action
that moves the caret one character
forwards, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionNextWordAction
Action
that moves the caret to the beginning
of the next word, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionPreviousWordAction
Action
that moves the caret to the beginning
of the previous word, possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectionUpAction
Action
that moves the caret one line up,
possibly extending the current selection.getActions()
,
Constant Field Valuespublic static final String selectLineAction
Action
that selects the line around the
caret.getActions()
,
Constant Field Valuespublic static final String selectParagraphAction
Action
that selects the paragraph around the
caret.getActions()
,
Constant Field Valuespublic static final String selectWordAction
Action
that selects the word around the
caret.getActions()
,
Constant Field Valuespublic static final String upAction
Action
that moves the caret one line up.getActions()
,
Constant Field Valuespublic static final String writableAction
Action
that sets the editor in read-write
mode.getActions()
,
Constant Field Valuespublic DefaultEditorKit()
DefaultEditorKit
.public Caret createCaret()
createCaret
in class EditorKit
Caret
for this EditorKit
public Document createDefaultDocument()
createDefaultDocument
in class EditorKit
Document
that this EditorKit
supportspublic Action[] getActions()
Action
s supported by this EditorKit
.getActions
in class EditorKit
Action
s supported by this EditorKit
public String getContentType()
EditorKit
supports.
The DefaultEditorKit
supports the content type
text/plain
.getContentType
in class EditorKit
EditorKit
supportspublic ViewFactory getViewFactory()
ViewFactory
that is able to create View
s for
the Element
s that are used in this EditorKit
's
model. This returns null which lets the UI of the text component supply
View
s.getViewFactory
in class EditorKit
ViewFactory
that is able to create View
s for
the Element
s that are used in this
EditorKit
's modelpublic void read(InputStream in, Document document, int offset) throws BadLocationException, IOException
InputStream
into the actual Document
object.read
in class EditorKit
in
- the stream from which to read the documentdocument
- the document model into which the content is readoffset
- the offset inside to document where the content is insertedBadLocationException
- if offset
is an invalid location
inside document
IOException
- if something goes wrong while reading from
in
public void read(Reader in, Document document, int offset) throws BadLocationException, IOException
read
in class EditorKit
in
- the reader from which to read the documentdocument
- the document model into which the content is readoffset
- the offset inside to document where the content is insertedBadLocationException
- if offset
is an invalid location
inside document
IOException
- if something goes wrong while reading from
in
public void write(OutputStream out, Document document, int offset, int len) throws BadLocationException, IOException
Document
(or a fragment of the
Document
) to an OutputStream
in the
supported content type format.write
in class EditorKit
out
- the stream to write todocument
- the document that should be written outoffset
- the beginning offset from where to writelen
- the length of the fragment to writeBadLocationException
- if offset
or
offset + len
is an invalid location inside
document
IOException
- if something goes wrong while writing to
out
public void write(Writer out, Document document, int offset, int len) throws BadLocationException, IOException
Document
(or a fragment of the
Document
) to a Writer
in the
supported content type format.write
in class EditorKit
out
- the writer to write todocument
- the document that should be written outoffset
- the beginning offset from where to writelen
- the length of the fragment to writeBadLocationException
- if offset
is an
invalid location inside document
.IOException
- if something goes wrong while writing to
out