Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.text
Class EditorKit

    java.lang.Object
      |
      +--javax.swing.text.EditorKit

Direct Known Subclasses:
  DefaultEditorKit

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

See Also:
  Serialized Form

Constructor Summary
`EditorKit()`

Method Summary
`abstract java.lang.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 java.lang.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(java.io.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(java.io.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(java.io.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(java.io.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
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### EditorKit

    public EditorKit()

Method Detail

### clone

    public abstract java.lang.Object clone()

  Creates a copy of the editor kit. This allows an implementation to serve as a prototype for others, so that they can be quickly created.
  Returns:
    the copy
  Overrides:
    clone in class java.lang.Object

### install

    public void install(JEditorPane c)

  Called when the kit is being installed into the a JEditorPane.
  Parameters:
    `c` - the JEditorPane

### deinstall

    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` - the JEditorPane

### getContentType

    public abstract java.lang.String getContentType()

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

### getViewFactory

    public abstract ViewFactory 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[] 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 createCaret()

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

### createDefaultDocument

    public abstract Document createDefaultDocument()

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

### read

    public abstract void read(java.io.InputStream in,
                              Document doc,
                              int pos)
                       throws java.io.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` - The stream to read from
    `doc` - The destination for the insertion.
    `pos` - The location in the document to place the content >= 0.
  Throws:
    java.io.IOException - on any I/O error
    BadLocationException - if pos represents an invalid location within the document.

### write

    public abstract void write(java.io.OutputStream out,
                               Document doc,
                               int pos,
                               int len)
                        throws java.io.IOException,
                               BadLocationException

  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:
    java.io.IOException - on any I/O error
    BadLocationException - if pos represents an invalid location within the document.

### read

    public abstract void read(java.io.Reader in,
                              Document doc,
                              int pos)
                       throws java.io.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` - The stream to read from
    `doc` - The destination for the insertion.
    `pos` - The location in the document to place the content >= 0.
  Throws:
    java.io.IOException - on any I/O error
    BadLocationException - if pos represents an invalid location within the document.

### write

    public abstract void write(java.io.Writer out,
                               Document doc,
                               int pos,
                               int len)
                        throws java.io.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` - 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:
    java.io.IOException - on any I/O error
    BadLocationException - if pos represents an invalid location within the document.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.