Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2005

Tip: Looking for answers? Try searching our database.

Need to change single node in JTree when JCheckbox selected

Thread view: 
brightoceanlight@hotmail.com - 12 Jul 2005 09:35 GMT
Hi,

I need to change the icon of just a single, particular node in a JTree
when a JCheckbox is selected.

I understand I will need to extend DefaultTreeCellRenderer to just
change the icon of a single node in the tree.  I've also extended
DefaultMutableTreeNode to give it more functionality.  But, I'm not
sure how to connect a checkbox to a particular tree node, and then have
the Renderer update the tree, based on the change?

Any help appreciated,

Thanks,

Gil
brightoceanlight@hotmail.com - 12 Jul 2005 13:38 GMT
I think I figured it out.

I need to keep the Nodes in the JTree global so they can be accessed by
ItemStateChanged or another listener attached to the checkbox.  Then a
field is changed in the node, which I have extended, and then
JTree.updateUI() is called to update the renderer.

This works okay so far.
Christian Kaufhold - 12 Jul 2005 20:07 GMT
> I need to keep the Nodes in the JTree global so they can be accessed by
> ItemStateChanged or another listener attached to the checkbox.  Then a
> field is changed in the node, which I have extended, and then
> JTree.updateUI() is called to update the renderer.
 ^^^^^^^^^^^^^^^^

Yikes!

Christian
brightoceanlight@hotmail.com - 13 Jul 2005 08:07 GMT
Hi Christian,

Why Yikes???

Is there a better way?

Gil
Christian Kaufhold - 15 Jul 2005 11:09 GMT
> Is there a better way?

DefaultTreeModel.nodeChanged

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.