Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Smart and Fast Tree

 
Kriss Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Kriss Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I do not know how to lazy load and cache. Please help.

Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic