I have this tree, whose nodes I create from a database. As I read in the details for each node, I create the node, add it to the Tree, and enter it into a hashMap.
Hi, I have a very similar business problem. I use an Oracle 8i
database stored procedure to return a cursor containing my list
of nodes and their properties.
1. I populate all the nodes into the JTree first right under the ROOT level.
2. then I make a second pass of the tree and move all the nodes under their parent nodes.
I have to make the second pass since I cannot add a node to a tree under a parent if the parent node doesn't yet exist (i.e. parent is farther down in my list). Yes, this second pass gets longer and longer as I move each child and have to search for its parent based on a Child's UserObject property (String parentnodeid).
This all works fine. I thought about perhaps using the HashMap idea but didn't (yet...). My JTree has about 1000 nodes so it isn't a trivial tree. The database retrieval using the cursor is 3 to 4 times as slow as the 1&2 pass tree populating routine so performance was not that big a deal.
Now here's the problem/issue and my design has me concerned:
I need to add 'searching' capabilities, expand/collapse, auto-scroll, just like you described. Since your Tree code seems to do EXACTLY what I need, any chance you could share it? I'd be most grateful.
Also I need a standard FIND, FINDNEXT java object that receives user input to search for, then I'd call my JTree search function.
I tried searching google, sun and the like but can't find source code for this very common object. BTW, I am using JBuilder 4 IDE.