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

Discussion in 'Java' started by Richie Williams, Oct 25, 2007.

  1. 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, Oct 25, 2007
    #1
    1. Advertising

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

    "Richie Williams" <> wrote in message
    news:ffqcpc$rae$...
    > 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, Oct 25, 2007
    #2
    1. Advertising

  3. Richie Williams

    Daniel Dyer Guest

    On Thu, 25 Oct 2007 16:36:50 +0100, Richie Williams
    <> wrote:

    > 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.

    --
    Daniel Dyer
    http://www.uncommons.org
    Daniel Dyer, Oct 25, 2007
    #3
  4. "Daniel Dyer" <"You don't need it"> wrote in message
    news:eek:...
    > On Thu, 25 Oct 2007 16:36:50 +0100, Richie Williams
    > <> wrote:
    >
    >> 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.
    >
    > --
    > Daniel Dyer
    > http://www.uncommons.org


    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!
    Richie Williams, Oct 25, 2007
    #4
  5. Richie Williams

    Daniel Dyer Guest

    On Thu, 25 Oct 2007 17:33:56 +0100, Richie Williams
    <> wrote:
    >
    > 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.

    --
    Daniel Dyer
    http://www.uncommons.org
    Daniel Dyer, Oct 25, 2007
    #5
  6. "Daniel Dyer" <"You don't need it"> wrote in message
    news:eek:...
    On Thu, 25 Oct 2007 17:33:56 +0100, Richie Williams
    <> wrote:
    >
    > 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.
    >
    >
    >--
    >Daniel Dyer
    >http://www.uncommons.org


    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!
    Richie Williams, Oct 25, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brandon McCombs

    custom JTree icons

    Brandon McCombs, Jan 13, 2006, in forum: Java
    Replies:
    4
    Views:
    28,318
    Thomas Hawtin
    Jan 14, 2006
  2. BinnuChowdary
    Replies:
    1
    Views:
    522
    Swanand Mokashi
    May 1, 2006
  3. BinnuChowdary
    Replies:
    0
    Views:
    404
    BinnuChowdary
    May 2, 2006
  4. BinnuChowdary
    Replies:
    1
    Views:
    539
    =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
    May 2, 2006
  5. jumpz
    Replies:
    3
    Views:
    616
    Jean-Baptiste Nizet
    Nov 12, 2007
Loading...

Share This Page