Xml syntax highlighting in Swing JTextPane
Skip to end of metadata
Go to start of metadata

Open sourced!!

This code is now published as an open source project on http://code.google.com/p/xml-text-editor/

A subclass of JTextPane that uses regular expressions for syntax highlighting.

First we extend JTextPane:

Next we define a custom EditorKit:

The EditorKit needs a ViewFactory:

Finally we create the syntax highlighting view:

  • No labels