Do i really have to implement the deep-clone myself or are there any library methods to get a deep clone of an JTree or it's TreeModel?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Just pass the root node and get the complete different root node and pass it to a new model of new tree.
As said by @SteveKuo, why do you need to clone a
TreeModel
?TreeModel
can be shared amongst different instances ofJTree
.Here is a sample demo of two JTree's sharing the same model. Alternatively, you could create twice the same
TreeModel
:Why do you need to clone both
JTree
andTreeModel
.JTree
is the view, which displays whatever the backingTreeModel
represents. If want to create a second identical tree, then you'd copy/clone the tree model, and create a newJTree
which points to the copiedTreeModel
.