Highlighter: getHighlights() : Highlighter « javax.swing.text « Java by API






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

1.implements Highlighter.HighlightPainter
2.Highlighter: addHighlight(int p0, int p1, HighlightPainter p)
3.Highlighter: removeAllHighlights()