Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

subclassing DefaultMutableTreeNode Class

 
parvin asadzadeh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have defined a subclass of DefaultMutableTreeNode Class in java :



in this class I have a recursive method called getsorted(ArrayList list_) , which accummulated the list_.

In this method, I have to call this.children() which returns the children of the node, but the children
are all of type "DefaultMutableTreeNode". I have to call the method getsorted on these children,
but since the getsorted is a mehtod of AccontsTreeNode, it gives me runtime cast error.

What is the best solution to these problem? Should I convert children to AccountTreeNode type by
overriding the children() method?
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why you should have that problem just because the method is declared in AccountsTreeNode; but then you haven't posted any of its code, nor have you posted the actual error message, so it's pretty hard to comment. In fact you haven't even said whether it's a compile-time or run-time message. So posting the details of your problem would be helpful. Have a look at our FAQ entry TellTheDetails (<-- click that link) for help on what kind of information you should be posting.

And, welcome to the Ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!