[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

JTree: How to remove rootHandles from all nodes in SOME trees in an application

Hi
I need to remove rootHandles from some trees in the application.
So, I can't set a general UIDefault or something like that to affect all trees.
showRootHandles(false) only operates on the root node as far as I can see.
Thanks
0
richard_fairall
Asked:
richard_fairall
  • 6
  • 5
1 Solution
 
objectsCommented:
The UI properties should only apply to any trees created *after* you change the property.
0
 
richard_fairallAuthor Commented:
Thanks for the replies (the one for connecting lines as well).
The connecting lines job works fine, using UIManager.put("Tree.paintLines", Boolean.FALSE);
However, I can't get rid of rootHandles on all nodes using UIManager.put("Tree.showsRootHandles", Boolean.FALSE);

Is this the correct default string? and Where on earth (Switzerland at the moment) do I find definitions of
the strings for the default UI stuff?
By the way, it's beer'oclock.
Thanks.
0
 
objectsCommented:
What L&F are you using?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
richard_fairallAuthor Commented:
Several look and feels,
Windows, EclipseL&F,  Metal, most are Jidesoft things.
Perhaps I have to set the UIDefault for showsRootHandles before
creating a node?
0
 
objectsCommented:
I would have thought the follwoing would work:

 tree.setShowsRootHandles(false);

Let me check and get back to you.

0
 
objectsCommented:
try setting UImanager properties "Tree.expandedIcon" and "Tree.collapsedIcon" to null.
0
 
richard_fairallAuthor Commented:
Tried  the following:

      UIManager.put("Tree.expandedIcon", null);
      UIManager.put("Tree.collapsedIcon", null);

No change, little  boxed + or  -  icon still there.


0
 
objectsCommented:
What L&F did u test it on?
0
 
richard_fairallAuthor Commented:
I have tried 6 different LAFs: Windows, eclipse metal, xerto (all from JideSoft inc)
They all still show the doobries.
Code is:
    UIManager.put("Tree.paintLines", Boolean.FALSE);
    UIManager.put("Tree.showsRootHandles", Boolean.FALSE);
    UIManager.put("Tree.expandedIcon", null);
    UIManager.put("Tree.collapsedIcon", null);

and:
    tree.putClientProperty("JTree.lineStyle", "None");
    renderer.putClientProperty("JTree.lineStyle", "None");

    tree.setShowsRootHandles(false);
    tree.setRootVisible(false);

The lines dont show.

0
 
objectsCommented:
Hmmm, try setting the expanded and collapsed icons to blank icons.
0
 
richard_fairallAuthor Commented:
OmiGawd
I forgot this trick! Works fine.

How to I find out about these resources like  "Tree.expandedIcon" ?

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now