Steve Luke wrote:
Michael Nana wrote:Hey guys,
... I initialized all the variables I am using in the paintcomponent so I don't see why I get flagged with it.
That is incorrect - if you did than you would not get a NullPointerException. The key is to recognize which Object was not initialized before it is used. If you give us the error message and the line where the error occurs it will probably help solve the problem. A quick look indicates that the String instructions may not be initialized before use. It looks like it (or any of the other Strings) might not get assigned until the actionPerformed on jTextField3 gets executed... Which means that you would get this NPE anytime the DrawPanel is visible without the text getting edited before hand.
Oh yeah sorry, the error is on line 265, instructions.length
Yeah I assumed that and that's why I have the jtextfield3 () method called in the paint component commented. When I remove the comment, I no longer get the NPE however the program doesn't behave like I wish. I have a method expandcode that I want it to expand the instructions when called but it doesn't do it.