Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DefaultTreeModel & JTree

 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a curios problem with a JTree.
When I use my own extended class for the TreeModel the Tree would not be filled, if I use the DefaultTreeModel directly it works.
What do I make wrong with my own TreeModel?

My TreeModel:

Call in the UI Class:
This don' t work:


This work:


I thought that when I extend my class with the DefaultTreeModel I will Inheritance all the function of superClass. Did I miss something?

Thank you very much

kind regards

Lars
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it just me or you're not using TreeViewModelNew at all ? Just a typo ?
 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

ups this was a copy and past failure, in eclipse my class is correct, I edit the posting above.
There is no failure message, just a empty JTree, when I use childcount in my TreeViewModel, it shows me an count of 1, but nothing in the JTree,

kind regards

Lars
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't you add the new node to the root of the tree ?
 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Christophe,

thank you very much for your fast help, this was the Point:

ptNode = new DefaultMutableTreeNode(root);

The failure was not to use the original root variable, the new created variable ptNode is different to the original root variable,

kind regards

Lars
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic