| Author |
curiosity regarding TreeModel
|
naved momin
Ranch Hand
Joined: Jul 03, 2011
Posts: 543
|
|
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
|
The Only way to learn is ...........do!
|
 |
Ranganathan Kaliyur Mannar
Ranch Hand
Joined: Oct 16, 2003
Posts: 386
|
|
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.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
 |
|
|
subject: curiosity regarding TreeModel
|
|
|