Search code examples
javaswinghighlightingjeditorpane

setting multiple highlighters to a jeditorpane


I want to know whether we can set two highlighters to a JEditorpane using sethighlighter(new Highlighter()) method where one is a default highlighter and the other is a underline highlighter.


Solution

  • You can use one highlighter but adding highlights with another HighlightPainter to paint your underline.

    public Object addHighlight(int p0, int p1, HighlightPainter p) throws BadLocationException;