This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Quick JTree Question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Quick JTree Question..." Watch "Quick JTree Question..." New topic

Quick JTree Question...

claude jones

Joined: Dec 14, 2001
Posts: 24
Is there a way to set a treeNode that does not currently contain any childern with the closedFolderIcon instead of the leafIcon?
If I created a node that allows childern, but is currently empty, I would like to display this node with the closedFolderIcon. This would be similar to an empty directory within a file system.
I plan on having a "Add Folder" and "Add Node" button to manipulate the tree.
When I add a rootNode to the JTree I get a leafIcon instead of the closedFolderIcon. I only get the closedFolderIcon once I have added a childNode to the rootNode.
Any ideas?
claude jones
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Claude,
Just one. Look at the following code. I have bolded the important items to do what you want.

claude jones

Joined: Dec 14, 2001
Posts: 24
Thanks for the reply. That did the trick!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Quick JTree Question...
Similar Threads
plus/minus sign in a jtree
JTree, adding and removing nodes contained in a master tree
jTree with the TreeModel