EditorKit (Java Platform SE 8 ) (original) (raw)
- javax.swing.text.EditorKit
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
DefaultEditorKit
public abstract class EditorKit
extends Object
implements Cloneable, Serializable
Establishes the set of things needed by a text component to be a reasonably functioning editor for some type of text content. The EditorKit acts as a factory for some kind of policy. For example, an implementation of html and rtf can be provided that is replaceable with other implementations.
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 it'ssetComponent
method called to establish it's relationship with a JTextComponent.
Constructor Summary
Constructors
Constructor Description EditorKit() Construct an EditorKit. Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods
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(JEditorPane c) 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(JEditorPane c) Called when the kit is being installed into the a JEditorPane. abstract void read(InputStream in,Document doc, int pos) Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. abstract void read(Reader in,Document doc, int pos) Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. abstract void write(OutputStream out,Document doc, int pos, int len) Writes content from a document to the given stream in a format appropriate for this kind of content handler. abstract void write(Writer out,Document doc, int pos, int len) Writes content from a document to the given stream in a format appropriate for this kind of content handler. * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[equals](../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../java/lang/Object.html#finalize--), [getClass](../../../java/lang/Object.html#getClass--), [hashCode](../../../java/lang/Object.html#hashCode--), [notify](../../../java/lang/Object.html#notify--), [notifyAll](../../../java/lang/Object.html#notifyAll--), [toString](../../../java/lang/Object.html#toString--), [wait](../../../java/lang/Object.html#wait--), [wait](../../../java/lang/Object.html#wait-long-), [wait](../../../java/lang/Object.html#wait-long-int-)`
Constructor Detail
* #### EditorKit public EditorKit() Construct an EditorKit.
Method Detail
* #### clone public [Object](../../../java/lang/Object.html "class in java.lang") clone() Creates a copy of the editor kit. This is implemented to use `Object.clone()`. If the kit cannot be cloned, null is returned. Overrides: `[clone](../../../java/lang/Object.html#clone--)` in class `[Object](../../../java/lang/Object.html "class in java.lang")` Returns: the copy See Also: [Cloneable](../../../java/lang/Cloneable.html "interface in java.lang") * #### install public void install([JEditorPane](../../../javax/swing/JEditorPane.html "class in javax.swing") c) Called when the kit is being installed into the a JEditorPane. Parameters: `c` \- the JEditorPane * #### deinstall public void deinstall([JEditorPane](../../../javax/swing/JEditorPane.html "class in javax.swing") c) Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached. Parameters: `c` \- the JEditorPane * #### getContentType public abstract [String](../../../java/lang/String.html "class in java.lang") getContentType() Gets the MIME type of the data that this kit represents support for. Returns: the type * #### getViewFactory public abstract [ViewFactory](../../../javax/swing/text/ViewFactory.html "interface in javax.swing.text") getViewFactory() Fetches a factory that is suitable for producing views of any models that are produced by this kit. Returns: the factory * #### getActions public abstract [Action](../../../javax/swing/Action.html "interface in javax.swing")[] 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. Returns: the set of actions * #### createCaret public abstract [Caret](../../../javax/swing/text/Caret.html "interface in javax.swing.text") createCaret() Fetches a caret that can navigate through views produced by the associated ViewFactory. Returns: the caret * #### createDefaultDocument public abstract [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") createDefaultDocument() Creates an uninitialized text storage model that is appropriate for this type of editor. Returns: the model * #### read public abstract void read([InputStream](../../../java/io/InputStream.html "class in java.io") in, [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") doc, int pos) throws [IOException](../../../java/io/IOException.html "class in java.io"), [BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text") Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. Parameters: `in` \- The stream to read from `doc` \- The destination for the insertion. `pos` \- The location in the document to place the content >= 0. Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- on any I/O error `[BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text")` \- if pos represents an invalid location within the document. * #### write public abstract void write([OutputStream](../../../java/io/OutputStream.html "class in java.io") out, [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") doc, int pos, int len) throws [IOException](../../../java/io/IOException.html "class in java.io"), [BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text") Writes content from a document to the given stream in a format appropriate for this kind of content handler. 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. Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- on any I/O error `[BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text")` \- if pos represents an invalid location within the document. * #### read public abstract void read([Reader](../../../java/io/Reader.html "class in java.io") in, [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") doc, int pos) throws [IOException](../../../java/io/IOException.html "class in java.io"), [BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text") Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler. 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. Parameters: `in` \- The stream to read from `doc` \- The destination for the insertion. `pos` \- The location in the document to place the content >= 0. Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- on any I/O error `[BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text")` \- if pos represents an invalid location within the document. * #### write public abstract void write([Writer](../../../java/io/Writer.html "class in java.io") out, [Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") doc, int pos, int len) throws [IOException](../../../java/io/IOException.html "class in java.io"), [BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text") Writes content from a document to the given stream in a format appropriate for this kind of content handler. 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. 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. Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- on any I/O error `[BadLocationException](../../../javax/swing/text/BadLocationException.html "class in javax.swing.text")` \- if pos represents an invalid location within the document.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.