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

Open sourced!!

This code is published as an open source project on https://github.com/kdekooter/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