NullPointerException in method!

public void addToWindowTextArea(String tmp)

{

String toAddToList= tmp;

ParentWindow.avbk.ShowInList(toAddToList); // NullPointerException

}

// ParentWindow = Main window

// avbk = childwindow that containes a Textarea

// ShowInList = method to add the text into the textarea

From a search method this method above receives a string. Here is the problem: when I try to send the results to

another method in the child window class the program crash... can someone help?

Thanks!

[552 byte] By [SonicBreezea] at [2007-9-29 16:23:17]
# 1

Try this and look which is null: public void addToWindowTextArea(String tmp){

String toAddToList= tmp;

System.out.println(ParentWindow);

System.out.println(avbk);

ParentWindow.avbk.ShowInList(toAddToList); // NullPointerException

}

PhHeina at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...
# 2

Hallo,

you need to solve your nullPointer problem.

As I see it, three objects could be null, ParentWindow, ParentWindow.avbk, or toAddToList. You need to find out which one is null and ensure that it is set correctly. If you are using a development environment with a reasonable debugger, you can set a breakpoint on the offending line, and then use the debugger to inspect the variables.

davidsingletona at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...
# 3
Either ParentWindow or avbk is null.Change your code so that neither is null. Or check to see if they're null before you try dereferencing them.That's all one can say given the code shown and your description of the problem.
paulcwa at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...
# 4
i think the problem is basically in the argument check the argument passed in the method itself...all the bestkk
kaushal_kka at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...
# 5
> i think the problem is basically in the argument > check the argument passed in the method itself...?
PhHeina at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...
# 6
Thanks guys! I discovered that the nullpoint problem was in the avbk class!Take care!
SonicBreezea at 2007-7-15 14:40:29 > top of Java-index,Archived Forums,Java Programming...