Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 213977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:19:48+00:00 2026-05-11T18:19:48+00:00

Using the new version of the substance look and feel for Java, the connecting

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:19:49+00:00Added an answer on May 11, 2026 at 6:19 pm

    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:

    1. You can call myTree.setUI( new MyTreeUI() )
    2. UIManager.getDefaults().put(“TreeUI”, MyTreeUI.class.getName() ) at some point before you make your JTree

    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:

    @Override
    protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds,
            Insets insets, Rectangle bounds, TreePath path, int row,
            boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
        boolean toPaint = (!this.tree.isEnabled())
                || this.isInside
                || !FadeConfigurationManager.getInstance().fadeAllowed(
                        SubstanceLookAndFeel.TREE_DECORATIONS_ANIMATION_KIND,
                        tree);
        if (FadeTracker.getInstance().isTracked(this.tree, SubstanceLookAndFeel.TREE_DECORATIONS_ANIMATION_KIND)) {
            Graphics2D graphics = (Graphics2D) g.create();
            graphics.setComposite(TransitionLayout
                    .getAlphaComposite(this.tree,
                            FadeTracker.getInstance()
                                .getFade10(this.tree,SubstanceLookAndFeel.TREE_DECORATIONS_ANIMATION_KIND) / 10.0f,
                                g));
            super.paintHorizontalPartOfLeg(graphics, clipBounds, insets,
                    bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
            graphics.dispose();
        } else if (toPaint) {
            super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path,
                    row, isExpanded, hasBeenExpanded, isLeaf);
        }
    }
    

    It looks like the lines are only painted if either of the following is true:

    • The Tree is not enabled, the mouse is in the tree bounds [this.inside] and fading (?) is not allowed on the tree [!FadeConfigurationManager.getInstance().fadeAllowed(…)]
    • The FadeTracker is tracking the JTree [FadeTracker.getInstance().isTracked(…)]

    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.

    public MyTree extends JTree {
        private boolean overrideIsEnable = false;
        public void setOverrideIsEnable(boolean b) { overrideIsEnabeld=true; }
        public boolean isOverrideIsEnable(boolean b) { return overrideIsEnabeld; }
        public boolean isEnabled() {
            if(overrideIsEnabled) return false;
            return super.isEnabled();
        }
    }
    
    
    class MyTreeUI extends SubstanceTreeUI {
    protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds,
            Insets insets, Rectangle bounds, TreePath path, int row,
            boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
    if(this.tree instanceof MyTree)
    try {
       Field f = SubstanceTreeUI.class.getDeclaredField("inside");
       f.setAccessible(true);
       Boolean v = (Boolean)f.get(this);
       f.set(this,Boolean.true);
       ((MyTree)this.tree).setOverrideIsEnable(true);
    } catch(Throwable t) {
       //want to default back to substanceUI if this fails.
    }
    super.paintHoriz.....();
    try{
        f.set(this,v);
        ((MyTree)this.tree).setOverrideIsEnable(true);
    }catch(Throwable t) {
       //see above
    }
    }
    //repeat for Vertical
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 435k
  • Answers 435k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Two things I see, alter your on click event to… May 15, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer Generally speaking, you should try and use the least specific… May 15, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer No your code is not correct. You are adding a… May 15, 2026 at 3:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.