Reputation: 2037
I need to store some data in a JTree
node. Is it possible to add a custom property to a node to hold my data?
Upvotes: 3
Views: 1256
Reputation: 44881
You can create a node class that extends say DefaultMutableTreeNode with a property for your data.
public final class MyDataNode extends DefaultMutableTreeNode {
private final MyData myData;
public MyDataNode(MyData myData) {
this.myData = myData;
}
public MyData getMyData() {
return myData;
}
}
Upvotes: 7