?
Solved

changing an icon on node in jtree

Posted on 2005-05-11
7
Medium Priority
?
338 Views
Last Modified: 2010-03-31
Hello,
I have an applet with one tree and 2 buttons "open" and "close". When I click open button, I want to change the image icon of the node which were selected on the tree.
Please give me the idea.
Thanks
0
Comment
Question by:nphnhi
  • 3
5 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 100 total points
ID: 13976777
0
 
LVL 92

Expert Comment

by:objects
ID: 13976779
exactly which icon is it you want to change?
you could try a defaultmutabletreenode with an ImageIcon as the nodes user object

0
 
LVL 92

Expert Comment

by:objects
ID: 13976789
0
 

Author Comment

by:nphnhi
ID: 13976800
for example, each node is a project with an icon "project_normal.gif". When I click open button, I want to change to "project_open.gif"
0
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 13983065
the following may be enough (add this before you create your tree):

UIManager.put ( "Tree.leafIcon", normalIcon ) ;
UIManager.put ( "Tree.openIcon", openIcon ) ;
UIManager.put ( "Tree.closedIcon", normalIcon ) ;

Otherwise see the example I posted above
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question