Get child of DefaultMutableTreeNode
Hello.
I have a DefaultMutableTreeNode.
This DMTN has several children.
I want to do something like this:
Code:
for(int i = 0; i< dmt.getChildCount(); i++){
[INDENT]System.out.println(dmt.getChildAt(i).getUserObject().toString());[/INDENT]
}
Simple enough. However, apparently the method getChildAt(int) returns an object of type TreeNode rather than DefaultMutableTreeNode.
TreeNodes don't have a getUserObject() method.
ALSO, I am not allowed to cast a TreeNode to a DefaultMutableTreeNode.
Seriously java? Why can't I get the child of a DefaultMutableTreeNode as a DefaultMutableTreeNode.
Please let me know if there is a method of doing what I want to do (iterate through the children of my dmtn and do something with their userObject).