0

Basically I need help with recursion. The point is that I am trying to make dialog which shows JTree with check boxes and I did it (copying most popular code here). But I can only copy whole tree from main frame, and what I need is selected component to be root of a new tree. So I guess I have to build new DefaultTreeModel for a new tree.

I tried every example I found ... from here to everywhere. I saw that people use recursion, but I can't apply codes that are given in right way or they just don't fit.

So this is my dialog class where I make new tree

It works when I try to check whole tree copied

But when I try to check copied subtree this is the result

This is the line with NullPointerException, somehow nodesCheckingState.get(tp) returns null, nodeCheckingState is hash map

I pasted whole code from here Java Swing: Need a good quality developed JTree with checkboxes

Ika
  • 11
  • 1

1 Answers1

0

I solved it! All I needed to do is to set parent of new root to null. :)

Ika
  • 11
  • 1