FileDocCategorySizeDatePackage
EditorKit.javaAPI DocJava SE 5 API5933Fri Aug 26 14:58:14 BST 2005javax.swing.text

EditorKit

public abstract class EditorKit extends Object implements Serializable, Cloneable
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's setComponent method called to establish it's relationship with a JTextComponent.

author
Timothy Prinzing
version
1.19 12/19/03

Fields Summary
Constructors Summary
public EditorKit()
Construct an EditorKit.

    
Methods Summary
public java.lang.Objectclone()
Creates a copy of the editor kit. This is implemented to use Object.clone. If the kit cannot be cloned, null is returned.

return
the copy

	Object o;
	try {
	    o = super.clone();
	} catch (CloneNotSupportedException cnse) {
	    o = null;
	}
	return o;
    
public abstract javax.swing.text.CaretcreateCaret()
Fetches a caret that can navigate through views produced by the associated ViewFactory.

return
the caret

public abstract javax.swing.text.DocumentcreateDefaultDocument()
Creates an uninitialized text storage model that is appropriate for this type of editor.

return
the model

public voiddeinstall(javax.swing.JEditorPane c)
Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached.

param
c the JEditorPane

    
public abstract javax.swing.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.

return
the set of actions

public abstract java.lang.StringgetContentType()
Gets the MIME type of the data that this kit represents support for.

return
the type

public abstract javax.swing.text.ViewFactorygetViewFactory()
Fetches a factory that is suitable for producing views of any models that are produced by this kit.

return
the factory

public voidinstall(javax.swing.JEditorPane c)
Called when the kit is being installed into the a JEditorPane.

param
c the JEditorPane

    
public abstract voidread(java.io.InputStream in, javax.swing.text.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.

param
in The stream to read from
param
doc The destination for the insertion.
param
pos The location in the document to place the content >= 0.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.

public abstract voidread(java.io.Reader in, javax.swing.text.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.

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.

param
in The stream to read from
param
doc The destination for the insertion.
param
pos The location in the document to place the content >= 0.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.

public abstract voidwrite(java.io.OutputStream out, javax.swing.text.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.

param
out The stream to write to
param
doc The source for the write.
param
pos The location in the document to fetch the content from >= 0.
param
len The amount to write out >= 0.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.

public abstract voidwrite(java.io.Writer out, javax.swing.text.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.

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.

param
out The stream to write to
param
doc The source for the write.
param
pos The location in the document to fetch the content >= 0.
param
len The amount to write out >= 0.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.