开发者

Java: How to select all descendants of a given ancestor on the Jtree?

开发者 https://www.devze.com 2023-03-20 02:57 出处:网络
I would like to select an ancestor DefaultMutableTreeNode and get all descendant DefaultMutableTreeNode of this ancestor in the JTree.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消