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

Posted on 2005-04-08
Last Modified: 2008-02-26

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?

Question by:richard_fairall
    LVL 3

    Expert Comment

    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?

    Author Comment

    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!

    LVL 3

    Accepted Solution

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

    Author Comment

    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.

    LVL 3

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    This article will show, step by step, how to integrate R code into a R Sweave document
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now