JTree: hide the connecting lines between nodes on selected trees.


I need to hide the connecting lines on some trees in our application, (but not on all trees).
The app uses a number of look and Feels (some from JideSoft inc) for Windows and Metal.
I have experimented with     tree.putClientProperty("JTree.lineStyle", "None");
but this only works on Java look and feel, not Windows types.
I have also tried     UIManager.put("Tree.paintLines", Boolean.FALSE);
but this turns them off across the entire application.

Any ideas?

Who is Participating?
I think that a possibility maybe that you set the global option before creating the tree, because thats the point i think, when it is initialized, and afterwards, you reset the global option. Dirty hack, it seems (And i don't know if it works, because changing an UI Property should make those trees receiving a property change event.).

Or... if you know which trees you want to change... try something like getUI(), cast to the appropriate UI list MetalTreeUI, and then interact directly with the UI. Or maybe, you generate property-Change-Events for the global properties yourself, and send them to the ui (even dirtier hack ;)
what exactly do you want? Disable all lines just for the windowLAF-Trees?
If you just want to disable them on some trees, why would you want to set a global property? And why don't you disable them just for the trees in which you don't need them?
richard_fairallAuthor Commented:
Thanks for the reply Mig-O but...

The first line states that I only want to set this option on specific trees in the application,
ie not all trees and therefore a global option is not possible.
Some trees have the lines, others don't.

The second line states that I need to do this for a number of look and feels (Windows and Java types)
The behaviour for all trees, with or without lines, must be consistent across all Look and Feel types.

You asked why don't I disable them just for the trees in which I don't need them ...
that's the solution I am asking for!

richard_fairallAuthor Commented:
Thanks again Mig-O
I'm a bit disappointed, this is the first time I have not received a clear answer to a question,
although, my colleagues say I've been really lucky in the past.
I'm surprised this is not a more common requirement but so la la.
I'm not sure where to go with this next, perhaps I should ask again in a short while.

I am sorry, not being able to help out more. maybe you can ask the question again with other words, and send "objects" or "CEJH" an mail to look at the question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.