Package com.inet.jortho
Class CheckerListener
- java.lang.Object
-
- com.inet.jortho.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 Summary
Fields Modifier and Type Field Description private Dictionarydictionaryprivate java.util.Localelocaleprivate javax.swing.JComponentmenuprivate SpellCheckerOptionsoptions
-
Constructor Summary
Constructors Constructor Description CheckerListener(javax.swing.JComponent menu, SpellCheckerOptions options)Create a PopupMenuListener
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddMenuItemAddToDictionary(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.protected voidaddSuggestionMenuItem(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.protected intgetCursorPosition(javax.swing.text.JTextComponent jText)Get the cursor position for the popup menuvoidlanguageChanged(LanguageChangeEvent ev)This method gets called when the language is changed.voidpopupMenuCanceled(javax.swing.event.PopupMenuEvent e)voidpopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)voidpopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent ev)
-
-
-
Field Detail
-
menu
private final javax.swing.JComponent menu
-
dictionary
private Dictionary dictionary
-
locale
private java.util.Locale locale
-
options
private final SpellCheckerOptions options
-
-
Constructor Detail
-
CheckerListener
public CheckerListener(javax.swing.JComponent menu, SpellCheckerOptions options)Create a PopupMenuListener- Parameters:
menu- a JMenu or JPopuupoptions- current spell checker options
-
-
Method Detail
-
popupMenuCanceled
public void popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
- Specified by:
popupMenuCanceledin interfacejavax.swing.event.PopupMenuListener
-
popupMenuWillBecomeInvisible
public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
- Specified by:
popupMenuWillBecomeInvisiblein interfacejavax.swing.event.PopupMenuListener
-
popupMenuWillBecomeVisible
public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent ev)
- Specified by:
popupMenuWillBecomeVisiblein interfacejavax.swing.event.PopupMenuListener
-
getCursorPosition
protected int getCursorPosition(javax.swing.text.JTextComponent jText) throws javax.swing.text.BadLocationExceptionGet 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 JTextComponentbegOffs- offset of the current word in the JTextComponent, need for replacementendOffs- end of the current word in the JTextComponent, need for replacementlist- a list with suggestionsneedCapitalization- 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 JTextComponentword- current word, which can be addaddSeparator- 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:
languageChangedin interfaceLanguageChangeListener- Parameters:
ev- A LanguageChangeEvent object describing the changes.
-
-