nullpointerexception - BlueJ call to public method null pointer exception (java.awt.container) -
normally instantiate panels inside of makeframe method, instead i'm required use 2 separate methods of createbuttonpanel() , createtextpanel(). problem being cannot work out how let makeframe use these when not inside of it's own method, , when i'm used javascript i've done looks should work, doesn't.

from screenshot, creating local variable in createbuttonpanel method making unavailable (null) add method of container.
public void createbuttonpanel() { jpanel buttonpanel = new jpanel(); } instead, make assign new instance class level variable won't null when passing add method of container.
public void createbuttonpanel() { this.buttonpanel = new jpanel(); // assigning class member } this should fix problem. also, advised move initializer method constructor calls , make private there no use of making public in case.
hope helps.
Comments
Post a Comment