|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.inet.jortho.SpellChecker
public class SpellChecker
This class is the major class of the spell checker JOrtho (Java Orthography Checker).
In the most cases this is the only class that you need to add spell checking to your application.
First you need to do a one-time registration of your dictionaries. In standalone applications this can
look like:
and in an applet this will look like:
SpellChecker.registerDictionaries( new URL("file", null, ""), "en,de", "de" );
After this you can register your text component that should have the spell checker features
(Highlighter, context menu, spell checking dialog).
This looks like:
SpellChecker.registerDictionaries( getCodeBase(), "en,de", "en" );
JTextPane text = new JTextPane();
SpellChecker.register( text );
Method Summary | |
---|---|
static void |
addLanguageChangeLister(LanguageChangeListener listener)
Adds a LanguageChangeListener. |
static javax.swing.JMenu |
createCheckerMenu()
Creates a menu item "Orthography" (or the equivalent depending on the user language) with a sub-menu that includes suggestions for a correct spelling. |
static javax.swing.JMenu |
createCheckerMenu(SpellCheckerOptions options)
Creates a menu item "Orthography" (or the equivalent depending on the user language) with a sub-menu that includes suggestions for a correct spelling. |
static javax.swing.JPopupMenu |
createCheckerPopup()
Create a dynamic JPopupMenu with a list of suggestion. |
static javax.swing.JPopupMenu |
createCheckerPopup(SpellCheckerOptions options)
Create a dynamic JPopupMenu with a list of suggestion. |
static javax.swing.JMenu |
createLanguagesMenu()
Creates a menu item "Languages" (or the equivalent depending on the user language) with a sub-menu that lists all available dictionary languages. |
static javax.swing.JMenu |
createLanguagesMenu(SpellCheckerOptions options)
Creates a menu item "Languages" (or the equivalent depending on the user language) with a sub-menu that lists all available dictionary languages. |
static void |
enableAutoSpell(javax.swing.text.JTextComponent text,
boolean enable)
Enable or disable the auto spell checking feature (red zigzag line) for a text component. |
static void |
enableAutoSpell(javax.swing.text.JTextComponent text,
boolean enable,
SpellCheckerOptions options)
Enable or disable the auto spell checking feature (red zigzag line) for a text component. |
static void |
enablePopup(javax.swing.text.JTextComponent text,
boolean enable)
Enable or disable the popup menu with the menu item "Orthography" and "Languages". |
static void |
enableShortKey(javax.swing.text.JTextComponent text,
boolean enable)
Enable or disable the F7 key. |
static void |
enableShortKey(javax.swing.text.JTextComponent text,
boolean enable,
SpellCheckerOptions options)
Enable or disable the F7 key. |
static java.lang.String |
getApplicationName()
Get the title of your application. |
static java.util.Locale |
getCurrentLocale()
Gets the current Locale . |
static CustomDictionaryProvider |
getCustomDictionaryProvider()
Gets the currently set CustomDictionaryProvider. |
static SpellCheckerOptions |
getOptions()
Get the default SpellCheckerOptions. |
static UserDictionaryProvider |
getUserDictionaryProvider()
Gets the currently set UserDictionaryProvider. |
static void |
register(javax.swing.text.JTextComponent text)
Activate the spell checker for the given JTextComponent . |
static void |
register(javax.swing.text.JTextComponent text,
boolean hasPopup,
boolean hasShortKey,
boolean hasAutoSpell)
Activates the spell checker for the given JTextComponent . |
static void |
registerDictionaries(java.net.URL baseURL,
java.lang.String activeLocale)
Registers the available dictionaries. |
static void |
registerDictionaries(java.net.URL baseURL,
java.lang.String availableLocales,
java.lang.String activeLocale)
Registers the available dictionaries. |
static void |
registerDictionaries(java.net.URL baseURL,
java.lang.String availableLocales,
java.lang.String activeLocale,
java.lang.String extension)
Registers the available dictionaries. |
static void |
removeLanguageChangeLister(LanguageChangeListener listener)
Removes the LanguageChangeListener. |
static void |
setApplicationName(java.lang.String name)
Set the title of your application. |
static void |
setCustomDictionaryProvider(CustomDictionaryProvider customDictionaryProvider)
Set a CustomDictionaryProvider. |
static void |
setUserDictionaryProvider(UserDictionaryProvider userDictionaryProvider)
Sets the UserDictionaryProvider. |
static void |
showSpellCheckerDialog(javax.swing.text.JTextComponent text,
SpellCheckerOptions options)
Show the Spell Checker dialog for the given JTextComponent. |
static void |
unregister(javax.swing.text.JTextComponent text)
Removes all spell checker features from the JTextComponent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void setUserDictionaryProvider(UserDictionaryProvider userDictionaryProvider)
registerDictionaries(URL, String, String)
.
userDictionaryProvider
- the new UserDictionaryProvider or nullsetCustomDictionaryProvider(CustomDictionaryProvider)
,
getUserDictionaryProvider()
,
registerDictionaries(URL, String, String)
public static UserDictionaryProvider getUserDictionaryProvider()
setUserDictionaryProvider(UserDictionaryProvider)
public static void setCustomDictionaryProvider(CustomDictionaryProvider customDictionaryProvider)
customDictionaryProvider
- the new CustomDictionaryProvider or nullsetUserDictionaryProvider(UserDictionaryProvider)
,
registerDictionaries(URL, String, String)
public static CustomDictionaryProvider getCustomDictionaryProvider()
setCustomDictionaryProvider(CustomDictionaryProvider)
public static void registerDictionaries(java.net.URL baseURL, java.lang.String activeLocale)
baseURL
- the base URL where the dictionaries and configuration file can be found. If null then URL("file", null, "")
is used.activeLocale
- the locale that should be loaded and made active. If null or empty then the default locale is used.public static void registerDictionaries(java.net.URL baseURL, java.lang.String availableLocales, java.lang.String activeLocale)
baseURL
- the base URL where the dictionaries can be found. If null then URL("file", null, "") is used.availableLocales
- a comma separated list of localesactiveLocale
- the locale that should be loaded and made active. If null or empty then the default locale is used.setUserDictionaryProvider(UserDictionaryProvider)
public static void registerDictionaries(java.net.URL baseURL, java.lang.String availableLocales, java.lang.String activeLocale, java.lang.String extension)
baseURL
- the base URL where the dictionaries can be found. If null then URL("file", null, "") is used.availableLocales
- a comma separated list of localesactiveLocale
- the locale that should be loaded and made active. If null or empty then the default locale is used.extension
- the file extension of the dictionaries. Some web server like the IIS6 does not support the default ".ortho".setUserDictionaryProvider(UserDictionaryProvider)
public static void register(javax.swing.text.JTextComponent text) throws java.lang.NullPointerException
JTextComponent
. The call is equal to register( text,
true, true ).
text
- the JTextComponent
java.lang.NullPointerException
- if text is nullpublic static void register(javax.swing.text.JTextComponent text, boolean hasPopup, boolean hasShortKey, boolean hasAutoSpell) throws java.lang.NullPointerException
JTextComponent
. You do not need to unregister if the
JTextComponent is not needed anymore.
text
- the JTextComponenthasPopup
- if true, the JTextComponent is to have a popup menu with the menu item "Orthography" and "Languages".hasShortKey
- if true, pressing the F7 key will display the spell check dialog.hasAutoSpell
- if true, the JTextComponent has a auto spell checking.
java.lang.NullPointerException
- if text is nullpublic static void unregister(javax.swing.text.JTextComponent text)
text
- the JTextComponentpublic static void enableShortKey(javax.swing.text.JTextComponent text, boolean enable)
text
- the JTextComponent that should changeenable
- true, enable the feature.public static void enableShortKey(javax.swing.text.JTextComponent text, boolean enable, SpellCheckerOptions options)
text
- the JTextComponent that should changeenable
- true, enable the feature.options
- override the default options for this menu.public static void showSpellCheckerDialog(javax.swing.text.JTextComponent text, SpellCheckerOptions options)
Action action = text.getActionMap().get("spell-checking");
The action is only available if you have enable the short key (F7).
text
- JTextComponent to checkoptions
- override the default options for this menu.public static void enablePopup(javax.swing.text.JTextComponent text, boolean enable)
text
- the JTextComponent that should changeenable
- true, enable the feature.public static void enableAutoSpell(javax.swing.text.JTextComponent text, boolean enable)
text
- the JTextComponent that should changeenable
- true, enable the feature.public static void enableAutoSpell(javax.swing.text.JTextComponent text, boolean enable, SpellCheckerOptions options)
text
- the JTextComponent that should changeenable
- true, enable the feature.options
- override the default options for this menu.public static void addLanguageChangeLister(LanguageChangeListener listener)
listener
- listener to addLanguageChangeListener
public static void removeLanguageChangeLister(LanguageChangeListener listener)
listener
- listener to removepublic static javax.swing.JMenu createCheckerMenu()
public static javax.swing.JMenu createCheckerMenu(SpellCheckerOptions options)
options
- override the default options for this menu.
public static javax.swing.JPopupMenu createCheckerPopup()
JPopupMenu popup = SpellChecker.createCheckerPopup();
text.addMouseListener( new PopupListener(popup) );
createCheckerMenu()
public static javax.swing.JPopupMenu createCheckerPopup(SpellCheckerOptions options)
JPopupMenu popup = SpellChecker.createCheckerPopup( null );
text.addMouseListener( new PopupListener(popup) );
createCheckerMenu(SpellCheckerOptions)
public static javax.swing.JMenu createLanguagesMenu()
JPopupMenu popup = new JPopupMenu();
popup.add( SpellChecker.createLanguagesMenu() );
public static javax.swing.JMenu createLanguagesMenu(SpellCheckerOptions options)
JPopupMenu popup = new JPopupMenu();
popup.add( SpellChecker.createLanguagesMenu() );
options
- override the default options for this menu.
public static java.util.Locale getCurrentLocale()
Locale
. The current Locale will be set if the user selects
one, or when calling
Locale
or null if none is set.registerDictionaries(URL, String, String)
public static void setApplicationName(java.lang.String name)
public static java.lang.String getApplicationName()
public static SpellCheckerOptions getOptions()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |