Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add spell checking to a JTextArea?

I have a small Java application that has a JTextArea where the user enters text. I would like to add spell checking capabilities to this component similar to the way that Microsoft Word does it, i.e. misspelled words are underlined and a popup menu with corrections is displayed when the user right clicks on the underlined word. Are there any open source libraries for adding this functionality to JTextAreas?

like image 903
TwentyMiles Avatar asked Oct 06 '09 05:10

TwentyMiles


2 Answers

You could implement your own spell checker using a dictionary (can get quite large depending on languages you support), then distance metrics are calculated from the words in the text box to the dictionary. Underlining can be done using font styling, there as applet based sample here.

Jaspell is a Java implementation of the popular Aspell. In there are some explantions of the search algorithms used.

As mentioned previously Jazzy is also great and IBM provides a nice tutorial.

like image 179
whatnick Avatar answered Sep 29 '22 08:09

whatnick


I haven't tried this before, but I came across it a little while ago: http://sourceforge.net/projects/jazzy/

like image 39
Aidos Avatar answered Sep 29 '22 07:09

Aidos