• Post Reply Bookmark Topic Watch Topic
  • New Topic

curiosity regarding TreeModel  RSS feed

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we build a jtree by passing model class which implements TreeModel interface
and in one of the constructor we do like

here my question is when this constructor will be called
does this model will have all the directories and sub-directories with in my home directory "user.home".
or it will just have top most directory
say like
just the directories within my home directory and no sub-directories
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:here my question is when this constructor will be called

It will be called when you invoke it. You usually do it by calling tree.setModel(new MyModelClass());
(btw, MyModelClass is poor naming, you can just name it MyTreeModel or MyModel).

naved momin wrote:does this model will have all the directories and sub-directories with in my home directory "user.home".


It won't. The 'user.home' is just a String here. Unless you implement the getChildCount() and getChild() the way you want to, considering the 'user.home' as a directory and reading the directory to get the list of files.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!