If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

gridbaglayout

i've made a simple frame with 2 labels, and and a JscrollPane, placed them in a GridBagLayout but everytime i try to run it, i get a nullpointerexception:

java.lang.NullPointerException
at Afbeelding.addComponent(Afbeelding.java:71)
at Afbeelding.<init>(Afbeelding.java:32)
at MyMenuBar.actionPerformed(MyMenuBar.java:60)
at java.awt.MenuItem.processActionEvent(MenuItem.java:588)
at java.awt.MenuItem.processEvent(MenuItem.java:548)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:285)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:273)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:452)
at java.awt.EventDispatchThread. pumpOneEventForHierarchy(EventDispatchTh

there is not enough information to compile your code.. hence i cannot determine if your code and mine are the same.. your error message shows that an element on line 72 is null, but when i paste your code into my edotor and look at it.. 72 is a method declaration.. go and look at line 72 of your code (cos i dont have the right code from you).. on line 72m, one of the things you are using has been declared but not initialized.