Class CheckerListener

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

    public class CheckerListener
    extends java.lang.Object
    implements javax.swing.event.PopupMenuListener, LanguageChangeListener
    Is used from CheckerMenu and CheckerPopup to handle the user events.
    • Field Detail

      • menu

        private final javax.swing.JComponent menu
      • locale

        private java.util.Locale locale
    • Constructor Detail

      • CheckerListener

        public CheckerListener​(javax.swing.JComponent menu,
                               SpellCheckerOptions options)
        Create a PopupMenuListener
        Parameters:
        menu - a JMenu or JPopuup
        options - current spell checker options
    • Method Detail

      • popupMenuCanceled

        public void popupMenuCanceled​(javax.swing.event.PopupMenuEvent e)
        Specified by:
        popupMenuCanceled in interface javax.swing.event.PopupMenuListener
      • popupMenuWillBecomeInvisible

        public void popupMenuWillBecomeInvisible​(javax.swing.event.PopupMenuEvent e)
        Specified by:
        popupMenuWillBecomeInvisible in interface javax.swing.event.PopupMenuListener
      • popupMenuWillBecomeVisible

        public void popupMenuWillBecomeVisible​(javax.swing.event.PopupMenuEvent ev)
        Specified by:
        popupMenuWillBecomeVisible in interface javax.swing.event.PopupMenuListener
      • getCursorPosition

        protected int getCursorPosition​(javax.swing.text.JTextComponent jText)
                                 throws javax.swing.text.BadLocationException
        Get the cursor position for the popup menu
        Parameters:
        jText - current JTextComponent
        Returns:
        the current position
        Throws:
        javax.swing.text.BadLocationException - should never occur
      • addSuggestionMenuItem

        protected void addSuggestionMenuItem​(javax.swing.text.JTextComponent jText,
                                             int begOffs,
                                             int endOffs,
                                             java.util.List<Suggestion> list,
                                             boolean needCapitalization)
        Add menu items to the with suggestions to the menu.
        Parameters:
        jText - current JTextComponent
        begOffs - offset of the current word in the JTextComponent, need for replacement
        endOffs - end of the current word in the JTextComponent, need for replacement
        list - a list with suggestions
        needCapitalization - if the first letter of the suggestion should capitalized
      • addMenuItemAddToDictionary

        protected void addMenuItemAddToDictionary​(javax.swing.text.JTextComponent jText,
                                                  java.lang.String word,
                                                  boolean addSeparator)
        Add the menu item "Add to Dictionary" at the end of the menu if a user dictionary is available.
        Parameters:
        jText - current JTextComponent
        word - current word, which can be add
        addSeparator - true, add a separator before the menu item
      • 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.