I'm looking for a way to display information in the format of a tree with multiple, connected root nodes. The root nodes would be located at the same depth in the tree, and have horizontal connections to one another, with child nodes being displayed below. I'm also hoping to be able to expand and collapse a branch of the tree by double clicking on the node.

I was previously using the abegoTreeLayoutForNetbeans package but I could not find a way to leverage it to work the way I needed, as it did not support horizontal node placement.

  • 2
    I didn't get it. Can you draw a wireframe to indicate what you want? Aug 30, 2016 at 8:03

1 Answer 1


I recommend using the default Tree functions of Java Swing and writing your own implementation of displaying them horizontally, you can extend on the existing ones that already cover the expand/collapse function.

Keep in mind that in Java Trees always have exactly one root node BUT you can tell the Tree to hide it, so it doesn't look like that. Use the tree.setRootVisible(false) call for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.