Colouring JTree's TreeNodes

Posted by Amadan on Stack Overflow See other posts from Stack Overflow or by Amadan
Published on 2010-05-24T03:28:20Z Indexed on 2010/05/24 3:30 UTC
Read the original article Hit count: 335

Filed under:
|

I have a JTree which I give objects that implement the TreeNode interface, and a custom TreeModel to display them (not using DefaultMutableTreeNode). I would like to change the text colour of some nodes. I can't find anything in the docs, except javax.swing.tree.DefaultTreeCellRenderer.setTextNonSelectionColor(Color newColor), but it will change everything indiscriminately, and I only need it for some nodes (specifically, broken links, i.e. nodes whose corresponding files can't be found on the disk, should be greyed out, the rest should be default). Can it be done, and how?

© Stack Overflow or respective owner

Related posts about java

Related posts about jtree