I've been using setCharacterAttributes of StyledDocument to change the colors of specific words or sections in a JTextPane.
But then I noticed some answers here where they use a Highlighter (typically DefaultHighlighter) to do the same thing.
What are the essential differences between the two approaches? What are some purposes for which using a highligher is better than manipulating the StyledDocument?