Rob Spoor wrote:Well, something on line 808 of file JTreeWithFTP.java is null.
Campbell Ritchie wrote:So, node is null at this point. Or, there is something in the getUserObject() method which is null and causing an Exception. Since 808 appears to be the top line in your stack trace, the first explanation is probably correct and the second probably incorrect.
Campbell Ritchie wrote:Start with line 807½See what that prints.
Campbell Ritchie wrote:What’s this about null leaf nodes? Have you got any null leaf nodes?
Look at this treeBut that isn’t how a binary tree works at all. You don’t have different node and leaf classes. Your leaves are nodes which don’t have children, but they still have pointers to those children, so they will point to null.
That means: Every binary tree is guaranteed to contain null pointers. In fact, I think you can work out how many nulls there are: I think it is n + 1 where n is the number of nodes.
Now I know a displayed tree is rather different from a binary tree, but you need to check
Do your leaf nodes have null pointers to their supposed children? Similarly to their user Objects? Should you be returning null if you pick up one of those leaves, or should you throw an Exception, to be caught higher up the stack, or should you do something different? Have you set a user Object, or put one there by any other means?
And what happened when you printed my is not null test from earlier (line 807½)?
Not sure I can go much rather. Sorry, I have probably suggested all I can. You will have to look harder for that null.
Anybody else, please?
Paul Clapham wrote:Come on, this isn't rocket science. Really. The simple solution is