Package com.inet.jortho
Class AutoSpellChecker
- java.lang.Object
-
- com.inet.jortho.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 aJTextComponentautomatically (in the background) for orthography. Spell error are highlighted with a red zigzag line.
-
-
Field Summary
Fields Modifier and Type Field Description private Dictionarydictionaryprivate javax.swing.text.JTextComponentjTextprivate java.util.Localelocaleprivate SpellCheckerOptionsoptionsprivate static RedZigZagPainterpainter
-
Constructor Summary
Constructors Constructor Description AutoSpellChecker(javax.swing.text.JTextComponent text, SpellCheckerOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangedUpdate(javax.swing.event.DocumentEvent ev)private voidcheckAll()// * Check the completely text.private voidcheckElement(javax.swing.text.Element element)Check the spelling of the text of an element.private voidcheckElements(int offset, int length)Check the Elements on the given position.(package private) static voiddisable(javax.swing.text.JTextComponent text)Remove the AutoSpellChecker from the given JTextComponent.voidinsertUpdate(javax.swing.event.DocumentEvent ev)voidlanguageChanged(LanguageChangeEvent ev)This method gets called when the language is changed.(package private) static voidrefresh(javax.swing.text.JTextComponent text)Refresh the highlighting.private static voidremoveHighlights(javax.swing.text.JTextComponent text)Remove all SpellChecker highlights from the given JTextComponent.voidremoveUpdate(javax.swing.event.DocumentEvent ev)
-
-
-
Field Detail
-
painter
private static final RedZigZagPainter painter
-
jText
private final javax.swing.text.JTextComponent jText
-
options
private final SpellCheckerOptions options
-
dictionary
private Dictionary dictionary
-
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:
changedUpdatein interfacejavax.swing.event.DocumentListener
-
insertUpdate
public void insertUpdate(javax.swing.event.DocumentEvent ev)
- Specified by:
insertUpdatein interfacejavax.swing.event.DocumentListener
-
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent ev)
- Specified by:
removeUpdatein interfacejavax.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:
languageChangedin interfaceLanguageChangeListener- Parameters:
ev- A LanguageChangeEvent object describing the changes.
-
-