Search code examples
javaxmljtree

How do I skin a Java JTree to look like it was meant for an xml document?


I have a JTree and the default look-and-feel of the icons and such look like it's meant for a file structure (with folder and document icons).

I'm wondering how I can override the look-and-feel programmatically, or via a library (Is there an XML JTree library?).


Solution

  • There's a very good example explained here along with source code.
    It's via getTreeCellRendererComponent() which you can further customize.
    It's also optimized for performance.