Top Description Constructors Methods
javax.swing.text

public abstract Class EditorKit

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Known Direct Subclasses
javax.swing.text.DefaultEditorKit
Annotations
@SuppressWarnings:serial
Imports
java.io.*, javax.swing.Action, .JEditorPane

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 its setComponent method called to establish its relationship with a JTextComponent.

Author
Timothy Prinzing

Constructor Summary

AccessConstructor and Description
public
EditorKit()

Construct an EditorKit.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the copy
clone
()

Overrides java.lang.Object.clone.

Creates a copy of the editor kit.
public abstract Caret

Returns:

the caret
createCaret
()

Fetches a caret that can navigate through views produced by the associated ViewFactory.

public abstract Document

Returns:

the model
createDefaultDocument
()

Creates an uninitialized text storage model that is appropriate for this type of editor.

public void
deinstall(JEditorPane
the JEditorPane
c
)

Called when the kit is being removed from the JEditorPane.

public abstract Action[]

Returns:

the set of actions
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.

public abstract String

Returns:

the type
getContentType
()

Gets the MIME type of the data that this kit represents support for.

public abstract ViewFactory

Returns:

the factory
getViewFactory
()

Fetches a factory that is suitable for producing views of any models that are produced by this kit.

public void
install(JEditorPane
the JEditorPane
c
)

Called when the kit is being installed into the a JEditorPane.

public abstract void
read(InputStream
The stream to read from
in
,
Document
The destination for the insertion.
doc
,
int
The location in the document to place the content >= 0.
pos
)

Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.

public abstract void
read(Reader
The stream to read from
in
,
Document
The destination for the insertion.
doc
,
int
The location in the document to place the content >= 0.
pos
)

Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.

public abstract void
write(OutputStream
The stream to write to
out
,
Document
The source for the write.
doc
,
int
The location in the document to fetch the content from >= 0.
pos
,
int
The amount to write out >= 0.
len
)

Writes content from a document to the given stream in a format appropriate for this kind of content handler.

public abstract void
write(Writer
The stream to write to
out
,
Document
The source for the write.
doc
,
int
The location in the document to fetch the content >= 0.
pos
,
int
The amount to write out >= 0.
len
)

Writes content from a document to the given stream in a format appropriate for this kind of content handler.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EditorKitback to summary
public EditorKit()

Construct an EditorKit.

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

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

Returns:Object

the copy

createCaretback to summary
public abstract Caret createCaret()

Fetches a caret that can navigate through views produced by the associated ViewFactory.

Returns:Caret

the caret

createDefaultDocumentback to summary
public abstract Document createDefaultDocument()

Creates an uninitialized text storage model that is appropriate for this type of editor.

Returns:Document

the model

deinstallback to summary
public void deinstall(JEditorPane c)

Called when the kit is being removed from the JEditorPane. This is used to unregister any listeners that were attached.

Parameters
c:JEditorPane

the JEditorPane

getActionsback to summary
public 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.

Returns:Action[]

the set of actions

getContentTypeback to summary
public abstract String getContentType()

Gets the MIME type of the data that this kit represents support for.

Returns:String

the type

getViewFactoryback to summary
public abstract ViewFactory getViewFactory()

Fetches a factory that is suitable for producing views of any models that are produced by this kit.

Returns:ViewFactory

the factory

installback to summary
public void install(JEditorPane c)

Called when the kit is being installed into the a JEditorPane.

Parameters
c:JEditorPane

the JEditorPane

readback to summary
public abstract void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException

Inserts content from the given stream which is expected to be in a format appropriate for this kind of content handler.

Parameters
in:InputStream

The stream to read from

doc:Document

The destination for the insertion.

pos:int

The location in the document to place the content >= 0.

Exceptions
IOException:
on any I/O error
BadLocationException:
if pos represents an invalid location within the document.
readback to summary
public abstract void read(Reader in, Document doc, int pos) throws IOException, BadLocationException

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:Reader

The stream to read from

doc:Document

The destination for the insertion.

pos:int

The location in the document to place the content >= 0.

Exceptions
IOException:
on any I/O error
BadLocationException:
if pos represents an invalid location within the document.
writeback to summary
public abstract void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException

Writes content from a document to the given stream in a format appropriate for this kind of content handler.

Parameters
out:OutputStream

The stream to write to

doc:Document

The source for the write.

pos:int

The location in the document to fetch the content from >= 0.

len:int

The amount to write out >= 0.

Exceptions
IOException:
on any I/O error
BadLocationException:
if pos represents an invalid location within the document.
writeback to summary
public abstract void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException

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:Writer

The stream to write to

doc:Document

The source for the write.

pos:int

The location in the document to fetch the content >= 0.

len:int

The amount to write out >= 0.

Exceptions
IOException:
on any I/O error
BadLocationException:
if pos represents an invalid location within the document.