Java – add custom attributes to JTree nodes
•
Java
I need to store some data in the JTree node Can I add custom attributes to the node to save my data?
Solution
You can create a node class with the extension defaultmutabletreenode, which contains data properties
public final class MyDatanode extends DefaultMutableTreeNode {
private final MyData myData;
public MyDatanode(MyData myData) {
this.myData = myData;
}
public MyData getMyData() {
return myData;
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
