The JEditorPane can display attributed text. If your text is static, that is you don’t want to highlight stuff while input, it’s quite easy to find text ranges with regular expressions and apply attributes the editor’s styled document.
If you want to create simply syntax highlighting for a text editor without bothering with styles and attributes, you can create something like this:
http://groups.google.com/groups?selm=bnqs3t%24qed%2403%241%40news.t-online.com
The text is German, but the code shown should be useful on its own. The example automatically highlights all occurences of “der”, “die” or “das” of MyEditor’s text. It creates a new EditorKit (the working horse behind the JEditorPane) to create a new ViewFactory to create a new View object for the plain text. View objects are responsible to render text (or graphics) in the JEditorPane.