Class AutoSpellChecker

  • All Implemented Interfaces:
    LanguageChangeListener, java.util.EventListener, javax.swing.event.DocumentListener

    class AutoSpellChecker
    extends java.lang.Object
    implements javax.swing.event.DocumentListener, LanguageChangeListener
    This class check a JTextComponent automatically (in the background) for orthography. Spell error are highlighted with a red zigzag line.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changedUpdate​(javax.swing.event.DocumentEvent ev)
      private void checkAll()
      // * Check the completely text.
      private void checkElement​(javax.swing.text.Element element)
      Check the spelling of the text of an element.
      private void checkElements​(int offset, int length)
      Check the Elements on the given position.
      (package private) static void disable​(javax.swing.text.JTextComponent text)
      Remove the AutoSpellChecker from the given JTextComponent.
      void insertUpdate​(javax.swing.event.DocumentEvent ev)
      void languageChanged​(LanguageChangeEvent ev)
      This method gets called when the language is changed.
      (package private) static void refresh​(javax.swing.text.JTextComponent text)
      Refresh the highlighting.
      private static void removeHighlights​(javax.swing.text.JTextComponent text)
      Remove all SpellChecker highlights from the given JTextComponent.
      void removeUpdate​(javax.swing.event.DocumentEvent ev)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • jText

        private final javax.swing.text.JTextComponent jText
      • locale

        private java.util.Locale locale
    • Constructor Detail

      • AutoSpellChecker

        public AutoSpellChecker​(javax.swing.text.JTextComponent text,
                                SpellCheckerOptions options)
    • Method Detail

      • disable

        static void disable​(javax.swing.text.JTextComponent text)
        Remove the AutoSpellChecker from the given JTextComponent.
        Parameters:
        text - the JTextComponent
      • removeHighlights

        private static void removeHighlights​(javax.swing.text.JTextComponent text)
        Remove all SpellChecker highlights from the given JTextComponent.
        Parameters:
        text - the JTextComponent
      • refresh

        static void refresh​(javax.swing.text.JTextComponent text)
        Refresh the highlighting. This can be useful if the dictionary was modify.
        Parameters:
        text - the JTextComponent
      • changedUpdate

        public void changedUpdate​(javax.swing.event.DocumentEvent ev)
        Specified by:
        changedUpdate in interface javax.swing.event.DocumentListener
      • insertUpdate

        public void insertUpdate​(javax.swing.event.DocumentEvent ev)
        Specified by:
        insertUpdate in interface javax.swing.event.DocumentListener
      • removeUpdate

        public void removeUpdate​(javax.swing.event.DocumentEvent ev)
        Specified by:
        removeUpdate in interface javax.swing.event.DocumentListener
      • checkElements

        private void checkElements​(int offset,
                                   int length)
        Check the Elements on the given position.
      • checkElement

        private void checkElement​(javax.swing.text.Element element)
        Check the spelling of the text of an element.
        Parameters:
        element - the to checking Element
      • checkAll

        private void checkAll()
        // * Check the completely text. Because this can consume many times with large Documents that this will do in a thread in the background step by step.
      • languageChanged

        public void languageChanged​(LanguageChangeEvent ev)
        This method gets called when the language is changed. This occurs if the user selects another language in the languages menu.
        Specified by:
        languageChanged in interface LanguageChangeListener
        Parameters:
        ev - A LanguageChangeEvent object describing the changes.