At 09:14 AM 2/13/2001 -0600, Brian Steele wrote:
>I've created a tree of Strings using DefaultMutableTreeNodes. Now I'm
>displaying the tree using JTree.
>
>I can change the background color of the tree using setBackground(), but
>this does not affect the leaves of the tree. Anyone know how to change the
>leaf background color?
>
>Thanks,
>Brian
All JTrees use a DefaultTreeCellRenderer unless told to do otherwise.
So, you can do this:
DefaultTreeCellRenderer renderer =
(DefaultTreeCellRenderer) myTree.getCellRenderer();
renderer.setBackground (myColor);
Other alternatives include subclassing DefaultTreeCellRenderer, or
setting the UIDefault for the property "Tree.textBackground".
If your JTree uses a different cell renderer, you'll have to figure out
how it determines which background color to use, and how to set it.
(It would be implementation-dependent.)
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing