I would like to select an ancestor DefaultMutableTreeNode
and get all descendant DefaultMutableTreeNode
of this ancestor in the JTree.
I am using TreeSelectionListener
to catch selection event on the current JTree.
Basically开发者_如何学运维, what I would like to be able to do is, select an ancestor node, and be able to copy it's descendant tree into another ancestor.
You should be able to walk the subtree recursively through the children() of the DMTN.
FWIW:
Maybe this will help a little, but ExampleDepot is a good site for Java example code, and they have a lot of Swing examples.
Here is a link to their set of JTree examples. I hope you find what you need.
http://www.exampledepot.com/egs/javax.swing.tree/pkg.html
精彩评论