Highlighter: getHighlights()
import javax.swing.JTextArea;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
public class Main {
public static void main(String[] argv) throws Exception {
JTextArea textComp = new JTextArea();
removeHighlights(textComp);
}
public static void removeHighlights(JTextComponent textComp) {
Highlighter hilite = textComp.getHighlighter();
Highlighter.Highlight[] hilites = hilite.getHighlights();
for (int i = 0; i < hilites.length; i++) {
hilite.removeHighlight(hilites[i]);
}
}
}
Related examples in the same category