This content has been marked as final. Show 3 replies
Where did you set gui to a valid value? Where is the code gui.sysOut()? Are you sure that gui is already correctly initialized at that point?
thanks for your quick reply...
basically there is the maingui... i press button1... i get a new frame (gui),
I want it to send a string back saying "loading"... the maingui has a output JTextArea... that is like a mini system out and reports actions... like file saved correctly etc.
Could you post the stacktrace? And indicate which lines of your code it is referring to?
If the NPE occured with "gui.sysOut("hello world")" - and not the output.append() line - then gui is null. You can check this using System.out.prinltn():
And, in that case, the question you asked about where gui was initialised is a good one: you need to examine your code at that point and figure out why gui didn't get a value, or got a value but was subsequently set to null.
System.out.println("gui=" + gui); gui.sysOut("hello world");