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 / General / October 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Richie Williams - 25 Oct 2007 16:34 GMT
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!
Richie Williams - 25 Oct 2007 16:40 GMT
To clarify I like get rid of those icon that Windows Tree contol shows plus
sign.

> Hello,
>
[quoted text clipped - 10 lines]
>
> Cheers!
Daniel Dyer - 25 Oct 2007 17:07 GMT
> Hello,
>
[quoted text clipped - 9 lines]
>
> Can anyone help?

The answer is in the API documentation:

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

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

Richie Williams - 25 Oct 2007 17:28 GMT
>> Hello,
>>
[quoted text clipped - 15 lines]
>
> Dan.

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);
}

Make my day!

Cheers!
Daniel Dyer - 25 Oct 2007 17:41 GMT
> Sorry but did not find answer there but it seems to be so that code like
> below:
[quoted text clipped - 7 lines]
>   ((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.

Signature

Daniel Dyer
http://www.uncommons.org

Richie Williams - 25 Oct 2007 17:57 GMT
On Thu, 25 Oct 2007 17:33:56 +0100, Richie Williams
<richie.williams@mailnox.com> wrote:

> Sorry but did not find answer there but it seems to be so that code like
> below:
[quoted text clipped - 7 lines]
>   ((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!


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.