Serializable
, Cloneable
DefaultEditorKit
public abstract class EditorKit extends Object implements Cloneable, Serializable
A kit can safely store editing state as an instance of the kit will be dedicated to a text component. New kits will normally be created by cloning a prototype kit. The kit will have its setComponent
method called to establish its relationship with a JTextComponent.
Constructor | Description |
---|---|
EditorKit() |
Construct an EditorKit. |
Modifier and Type | Method | Description |
---|---|---|
Object |
clone() |
Creates a copy of the editor kit. |
abstract Caret |
createCaret() |
Fetches a caret that can navigate through views produced by the associated ViewFactory. |
abstract Document |
createDefaultDocument() |
Creates an uninitialized text storage model that is appropriate for this type of editor. |
void |
deinstall |
Called when the kit is being removed from the JEditorPane. |
abstract Action[] |
getActions() |
Fetches the set of commands that can be used on a text component that is using a model and view produced by this kit. |
abstract String |
getContentType() |
Gets the MIME type of the data that this kit represents support for. |
abstract ViewFactory |
getViewFactory() |
Fetches a factory that is suitable for producing views of any models that are produced by this kit. |
void |
install |
Called when the kit is being installed into the a JEditorPane. |
abstract void |
read |
Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. |
abstract void |
read |
Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. |
abstract void |
write |
Writes content from a document to the given stream in a format appropriate for this kind of content handler. |
abstract void |
write |
Writes content from a document to the given stream in a format appropriate for this kind of content handler. |
public EditorKit()
public Object clone()
Object.clone()
. If the kit cannot be cloned, null is returned.public void install(JEditorPane c)
c
- the JEditorPanepublic void deinstall(JEditorPane c)
c
- the JEditorPanepublic abstract String getContentType()
public abstract ViewFactory getViewFactory()
public abstract Action[] getActions()
public abstract Caret createCaret()
public abstract Document createDefaultDocument()
public abstract void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException
in
- The stream to read fromdoc
- The destination for the insertion.pos
- The location in the document to place the content >= 0.IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.public abstract void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException
out
- The stream to write todoc
- 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
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.public abstract void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
Since actual text editing is unicode based, this would generally be the preferred way to read in the data. Some types of content are stored in an 8-bit form however, and will favor the InputStream.
in
- The stream to read fromdoc
- The destination for the insertion.pos
- The location in the document to place the content >= 0.IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.public abstract void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
Since actual text editing is unicode based, this would generally be the preferred way to write the data. Some types of content are stored in an 8-bit form however, and will favor the OutputStream.
out
- The stream to write todoc
- The source for the write.pos
- The location in the document to fetch the content >= 0.len
- The amount to write out >= 0.IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/text/EditorKit.html