permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes JTree-  setting color for specific nodes in the tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree-  setting color for specific nodes in the tree" Watch "JTree-  setting color for specific nodes in the tree" New topic
Author

JTree- setting color for specific nodes in the tree

Aruna Devi
Greenhorn

Joined: Nov 08, 2000
Posts: 2
Hi,
I am trying to set different color for specific nodes in a JTree based on certain conditions.
When I browsed thru lot of sun tutorials and others, I came across TreeCellRenderer class.
I created a DefaultTreeCellRenderer object and attached to the tree through <treeobject>.setCellRenderer( renderer object ).
Then I have put the condition and depending on that I have used the setTextNonSelectionColor() method to try to the change the color. But then this method changes the color for all nodes made later and not for the specific node only.
Please throw some light on this issue.
I would greatly appreciate the help.
Thanks,
Aruna
Craig Snowbarger
Ranch Hand

Joined: Mar 07, 2001
Posts: 38
Originally posted by Aruna Devi:
Hi,
I am trying to set different color for specific nodes in a JTree based on certain conditions.
When I browsed thru lot of sun tutorials and others, I came across TreeCellRenderer class.
I created a DefaultTreeCellRenderer object and attached to the tree through <treeobject>.setCellRenderer( renderer object ).
Then I have put the condition and depending on that I have used the setTextNonSelectionColor() method to try to the change the color. But then this method changes the color for all nodes made later and not for the specific node only.
Please throw some light on this issue.
I would greatly appreciate the help.
Thanks,
Aruna

Did you ever figure out how to do this?
panyam km
Greenhorn

Joined: May 03, 2001
Posts: 3
hi.,
can u able to send the code and for time being u can check http://www2.gol.com/users/tame/swing/examples/JTreeExamples1.html
bye
panyam
------------------
vinod ac
Greenhorn

Joined: Jul 08, 2001
Posts: 9
hi aruna devi
follow the link and u will get the answer for ur question
http://www2.gol.com/users/tame/swing/examples/JTreeExamples2.html
George Thomas
Ranch Hand

Joined: Oct 06, 2000
Posts: 35
Here's some tree cell renderer code:
(ConfigTreeNode is a sub class of DefaultMutableTreeNode)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree- setting color for specific nodes in the tree
 
Similar Threads
JTree
Jtree problem
Expanding a Specific Node in JTree
JTree
JTree