views:

41

answers:

1

Hello,

I'm looking to build a tree-like structure for my Java application. I've tried using libraries such as Prefuse and Jung, but they do not seem to (easily, at least) allow me to dynamically expand the trees based on users' selections.

For example, here is a starting tree:

         Branch
         Branch
Root ->  Branch
         Branch
         Branch

Now, the user can select any one of these branches to expand. The catch, though, is that the results of clicking a branch needs to be processed at run time. So after clicking the first branch and my processing is done, I would like to update the tree to look like this:

                    Branch
                    Branch
         Branch ->  Branch
         Branch
Root ->  Branch
         Branch
         Branch

This can happen an unlimited (available space permitting) number of times.

In my reserach, I've found graphing libraries such as those listed above to be too complex for this (seemingly simple) task. Also, I would like to avoid JTree as it doesn't fit my view of this project.

My ideal solution is some type of custom Tree that gives the look of this Prefuse sample but with the ease of use of a simple tree structure (like JTree).

Any ideas and suggestions are most welcome and appreciated. Thanks for reading.

+2  A: 

Have you thought about using a custom rendering for JTree ? Like a specific look'n'feel ? Indeed, JTree is precisely focused on object tree representation.

Riduidel
Agreed. For a custom behavior and look, like the one you describe, you will need to create your own TreeCellRenderer implementation (to fit into your "view of this project") and your own TreeModel to look up the new branches dynamically.
Amber Shah