Can anyone provide a working sample code to convert following Oracle DB table with parent-child relation to a JTree in Java code?
Table T (columns: Id, Parent_Id, Description).
I have searched many similar questions but all seems vague and incomplete for someone who is new to JTree. I dont need any code to connect to DB but only to go over the results and populating the JTree.
Thanks
When I started with JTree I implemented this class that seems pretty similar with your problem.
Check methods:
getElementTreeFromPlainListthat is more or less the method that you would use to fetch data from persistent layer and methodcreateTreeNodesForElementthat creates the nodes for the tree.