I\'m looking for a way to display information in the format of a tree with multi
ID: 657642 • Letter: I
Question
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.
Explanation / Answer
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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.