I am trying to convert a postfix expression to an expression tree. My method is to have a stack of JTree for the expression tree, a stack of string for paranthesis and a stack of nodes for operators.
Eg postfi ( C ( A B OR ) AND )
I am able to populate the stacks but when I encounter a ')' I want to create a new JTree in the JTree stack which will contain the operator stack's pop (operator JTree) as root, and the two expression JTrees (pop the expression stack twice) as children.
When I try to create a new tree, as above, I am unable to add the two popped JTrees to the parent operator JTree. Is there another way to do this? How can I nest 2 JTrees? Please tell me if I am not clear/ need to post code.