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 aJTextComponent
automatically (in the background) for orthography. Spell error are highlighted with a red zigzag line.
-
-
Field Summary
Fields Modifier and Type Field Description private Dictionary
dictionary
private javax.swing.text.JTextComponent
jText
private java.util.Locale
locale
private SpellCheckerOptions
options
private static RedZigZagPainter
painter
-
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 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)
-
-
-
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:
changedUpdate
in interfacejavax.swing.event.DocumentListener
-
insertUpdate
public void insertUpdate(javax.swing.event.DocumentEvent ev)
- Specified by:
insertUpdate
in interfacejavax.swing.event.DocumentListener
-
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent ev)
- Specified by:
removeUpdate
in 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:
languageChanged
in interfaceLanguageChangeListener
- Parameters:
ev
- A LanguageChangeEvent object describing the changes.
-
-