如何将拼写检查添加到JTextArea? [英] How do I add spell checking to a JTextArea?

查看:123
本文介绍了如何将拼写检查添加到JTextArea?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型Java应用程序,它有一个JTextArea,用户可以在其中输入文本。我想为此组件添加拼写检查功能,类似于Microsoft Word的方式,即拼写错误的单词加下划线,当用户右键单击带下划线的单词时,会显示带有更正的弹出菜单。有没有用于向JTextAreas添加此功能的开源库?

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?

推荐答案

您可以使用字典实现自己的拼写检查(可以根据您支持的语言变得非常大),然后根据文本框中的单词计算距离度量。可以使用字体样式进行下划线,基于applet的样本此处

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 是一个Java实现的流行的Aspell。在使用的搜索算法中有一些解释。

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

如前所述,Jazzy也很棒,IBM提供了很好的教程

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

这篇关于如何将拼写检查添加到JTextArea?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆