Java tutorial
//package com.java2s; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; public class Main { public static void removeHighlights(JTextComponent textComp) { Highlighter hilite = textComp.getHighlighter(); Highlighter.Highlight[] hilites = hilite.getHighlights(); for (int i = 0; i < hilites.length; i++) { if (hilites[i].getPainter() instanceof Highlighter) { hilite.removeHighlight(hilites[i]); } } } }