This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Smart and Fast Tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Smart and Fast Tree" Watch "Smart and Fast Tree" New topic
Author

Smart and Fast Tree

Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hi,

I would like to create a tree which would load as shown below:

C:\
------>Folder-1
------>Folder-2
------>Folder-3

When Folder-1 is selected I want to display as shown below:
C:\
------>Folder-1
|----------->Folder-1.1
|----------->Folder-1.2
|----------->File1.1

and when Folder-1.1 is selected, I want to display as shown below:

C:\
------>Folder-1
|-------->Folder-1.1
|-------->Folder-1.1.1
|-------->File-1.1.1

and I do not want to load children in any other folders other than selected because it takes a lot of time to load the tree.

Please let me know the approach that I should take to implement this functionality.

Thanks in advance.
Kriss


Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

In the other thread which you had hijacked Rob gave some tips on how do lazy load a tree with caching. Did you try it out?
What have you got so far, and were exactly are you stuck?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hi,
I do not know how to lazy load and cache. Please help.

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I went to the API documentation for JTree and started searching for the word "listener". Pretty soon I came to a method called "addTreeExpansionListener" whose short description says
Adds a listener for TreeExpansion events.
Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hi Paul,

Thanks for your pointer, I noticed that. How does a JTree load its children by default? ie what is the default way of loading its children, what conditions determine this behaviour?

Please point to some easy to understand 'basics' tutorial of JTree, some sun's tutorials are too complicated for me.

Thanks.
Kriss
 
wood burning stoves
 
subject: Smart and Fast Tree
 
Similar Threads
dtree
Difficulties with setting up Apache tomcat: 'Need a little help.
How to show icons in Tree using DOJO 0.4
hierarchy
How to recursively traverse JTree?