and the JReportFrame constructor that receives this:
Adam Cripps wrote:I want to save some preferences when the user closes the JFrame. I've implemented the WindowEvent to pick this up and set setDefaultCloseOperation(JFrame.DO_NOTHING). I'm calling the applications variable prefs.flush() which is giving the NullPointerException. I'm guessing that the nullpointerexception is thrown because I'm not actually handling the instance of jreport.prefs that I think I am. I would like some help finding out where I'm going wrong with handling the jreport.prefs instance. I declare JReport jreport in JReportFrame (which is instantiated by JReport)...
The easiest thing to do is probably to add some debugging statements to print out the contents of the possible culprits, viz:it won't tell you why, but it may help you to narrow down the problem.
Adam Cripps wrote:Am I correct in thinking that if I pass the jreport instance to the constructor and that with the declaration at the beginning of the class (JReport jreport;) that the whole class should be able to see jreport?
No. You have to assign the jreport you pass to your constructor to the member variable. In your constructor you need the line