javax.swing.text

Class 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's setComponent method called to establish it's relationship with a JTextComponent.

    • Constructor Summary

      Constructors 
      Constructor and Description
      EditorKit()
      Construct an EditorKit.

        

    • Method Summary

      Methods 
      Modifier and Type Method and 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.

        

    • Constructor Detail

      • EditorKit

        public EditorKit()
        Construct an EditorKit.
    • Method Detail

      • clone

        public 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.
        Overrides:
        clone in class Object
        Returns:
        the copy
        See Also:
        Cloneable
      • 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 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(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 - The stream to read from
        doc - The destination for the insertion.
        pos - The location in the document to place the content >= 0.
        Throws:
        IOException - on any I/O error
        BadLocationException - if pos represents an invalid location within the document.
      • write

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

        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 - The stream to read from
        doc - The destination for the insertion.
        pos - The location in the document to place the content >= 0.
        Throws:
        IOException - on any I/O error
        BadLocationException - if pos represents an invalid location within the document.
      • write

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

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

06/11/2024 00:12:47 Cette version de la page est en cache (à la date du 06/11/2024 00:12:47) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.

Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/text/editorkit.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, EditorKit

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut