diff --git a/languagetool-standalone/src/main/java/org/languagetool/gui/LanguageToolSupport.java b/languagetool-standalone/src/main/java/org/languagetool/gui/LanguageToolSupport.java
index <HASH>..<HASH> 100644
--- a/languagetool-standalone/src/main/java/org/languagetool/gui/LanguageToolSupport.java
+++ b/languagetool-standalone/src/main/java/org/languagetool/gui/LanguageToolSupport.java
@@ -811,7 +811,9 @@ class LanguageToolSupport {
 
   private void removeHighlights() {
     for (Highlighter.Highlight hl : textComponent.getHighlighter().getHighlights()) {
-      textComponent.getHighlighter().removeHighlight(hl);
+      if (hl.getPainter() instanceof HighlightPainter) {
+        textComponent.getHighlighter().removeHighlight(hl);
+      }
     }
   }
fix drawing problems: selected text could sometimes disappear (e.g. when selecting text after start up, but before the first errors were marked)