Using the new version of the substance look and feel for Java, the connecting lines in a typical JTree are not drawn (parent – child lines).
In the official forum in java.net someone asked the same thing and the answer of the developer for this is that it was a choice based on the newer UI’s and there is no plan to implement the option in the future.
His answer also said that you could implement this yourself by subclassing the SubstanceUI class and implementing the paintHorizontalPartOfLeg / paintVerticalPartOfLeg methods.
Can someone either explain the process needed or maybe give me an example? I’m sure that someone must have done this since it is a very weird choice on behalf of the developer not to draw these lines.
This is all going from memory. I will edit if I find anything wrong with this tomorrow.
check out BasicTreeUI or MetalTreeUI. I believe they both paint lines.
What you need to do is create a new class that extends (I’m guessing on the name here) SubstanceTreeUI and override paintHorizontalPartOfLeg() and paintVerticalPartOfLeg(). Then you have a choice:
If you don’t want to subclass, try UIManager.getDefaults().put(“TreeUI”, BasicTreeUI.class.getName() ) and see if that looks ok.
EDIT 2:
After further review it would be easier to just call .setUI(new BasicTreeUI()) on your JTree or call UIManager.getDefaults().put(“TreeUI”, BasicTreeUI.class.getName() ) before creating your tree.
EDIT:
SubstanceTreeUI is a cubclass of BasicTreeUI. It has overridden paintXXXPartOfLeg().
Horiz:
It looks like the lines are only painted if either of the following is true:
Figure out how to ensure that the JTree is being Tracked by the FadeTracker or try this VERY rough hack (see below):
You could also cut and paste the code from BasicTreeUI’s paintXXXPartOfLeg methods into a subclass.