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 Dictionary
dictionary
private java.util.Locale
locale
private javax.swing.JComponent
menu
private SpellCheckerOptions
options
-
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 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.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.protected int
getCursorPosition(javax.swing.text.JTextComponent jText)
Get the cursor position for the popup menuvoid
languageChanged(LanguageChangeEvent ev)
This method gets called when the language is changed.void
popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
void
popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
void
popupMenuWillBecomeVisible(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:
popupMenuCanceled
in interfacejavax.swing.event.PopupMenuListener
-
popupMenuWillBecomeInvisible
public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
- Specified by:
popupMenuWillBecomeInvisible
in interfacejavax.swing.event.PopupMenuListener
-
popupMenuWillBecomeVisible
public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent ev)
- Specified by:
popupMenuWillBecomeVisible
in interfacejavax.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 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:
languageChanged
in interfaceLanguageChangeListener
- Parameters:
ev
- A LanguageChangeEvent object describing the changes.
-
-