Back to LanguageTool Homepage - Privacy - Imprint

Highlighting Errors


(jtcady) #1

I am using the LanguageTool in a desktop java application that I created. It gets the text from an imported file in a JTextArea and it checks for errors fine but how do I get it to show the highlighting of the errors? (Red: spelling error, Yellow: grammar error)

Thanks


(pminos) #2

Hi jtcady,

You get no highlights for errors or you see the highlights but you want them to have another color?

The colors for the HighlightPainters are currently hardcoded, but if there is a need for custom colors, we can provide some setters.

regards,
Panagiotis Minos


(jtcady) #3

I do not get highlights for errors as in I see no color markings.

Thanks


(pminos) #4

Hello jtcady,

You can use org.languagetool.gui.LanguageToolSupport for adding grammar checking support to a JTextComponent. This will handle highlights.

I will create a sample project and upload it later or tomorrow.

Regards,
Panagiotis Minos


(jtcady) #5

Okay, thank you!!


(pminos) #6

Hi,

I prepared a small demo. You can download it from the following URL

https://github.com/pminos/languagetool-wrapper-demo-parent

The project has two maven modules. The languagetool-wrapper module contains the needed classes for adding highlighting to a JTextComponent. The languagetool-wrapper-demo module contains code that creates a Window with a JTextArea. The last two lines in the constructor are responsible for adding grammar checking to the textarea.

Best regards,
Panos