JTree and those small Icons ahead folder, file etc icons.

R

Richie Williams

Hello,

How can I remove those small icons that comes to front of each node
that are in JTree. I mean those small images that looks like hanheld mirros
or something.
I want lines connecting each node to it's parent and folder and leaf icon
but icon that
I mentioned I gladly remove.

I have seen a snippet how to remove them but can't find it anywhere.

Can anyone help?

Cheers!
 
R

Richie Williams

To clarify I like get rid of those icon that Windows Tree contol shows plus
sign.
 
D

Daniel Dyer

Hello,

How can I remove those small icons that comes to front of each node
that are in JTree. I mean those small images that looks like hanheld
mirros
or something.
I want lines connecting each node to it's parent and folder and leaf icon
but icon that
I mentioned I gladly remove.

I have seen a snippet how to remove them but can't find it anywhere.

Can anyone help?

The answer is in the API documentation:

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTree.html#setShowsRootHandles(boolean)

Dan.
 
R

Richie Williams

D

Daniel Dyer

Sorry but did not find answer there but it seems to be so that code like
below:

JTree tree = new JTree(root);

ComponentUI treeUI = tree.getUI();
if(treeUI instanceof BasicTreeUI)
{
((BasicTreeUI) treeUI).setExpandedIcon(null);
((BasicTreeUI) treeUI).setCollapsedIcon(null);
}

Which "thing" are you trying to hide? If you want to hide the control on
the very left that expands/collapses the branches, then you use
setShowsRootHandles. If you want hide the folder/file icons that are
rendered for each node, then your code is a solution for that.

Dan.
 
R

Richie Williams

"Daniel Dyer" <"You don't need it"> wrote in message
Sorry but did not find answer there but it seems to be so that code like
below:

JTree tree = new JTree(root);

ComponentUI treeUI = tree.getUI();
if(treeUI instanceof BasicTreeUI)
{
((BasicTreeUI) treeUI).setExpandedIcon(null);
((BasicTreeUI) treeUI).setCollapsedIcon(null);
}
Which "thing" are you trying to hide? If you want to hide the control on
the very left that expands/collapses the branches, then you use
setShowsRootHandles. If you want hide the folder/file icons that are
rendered for each node, then your code is a solution for that.

Dan.

Hello,

Yep I was using hiding for the latter situation you mentioned.
In my case those collapse icons were not suitable for GUI
because they looked peculiar in my LookAndFeel.
I handle folders with folder open / close icons.

Of course I also changed the color or the lines connecting
each node to their parents.

Seems good now!

Cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top