Java,这是争论

时间:2013-04-21 13:07:57

标签: java nullpointerexception this

我正在尝试构建一个需要将自己传递给另一个的类,但是当我尝试这个时,我总是得到一个NullPointerException。我应该先查看什么?我使用netbeans并使用断点检查,但对象是正确的,而不是null。

代码

class Kartya {
...
  public void setVisible(boolean bool) {
    MainJFrame.slotpool.addKGepSlots(this);
  }
}

堆栈跟踪:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at jatek.kartya.Kartya.setVisible(Kartya.java:193)
    at jatek.jatekos.EmberiJatekos.lapHozzaad(EmberiJatekos.java:66)
    at gui.MainJFrame.huz(MainJFrame.java:88)
    at gui.MainJFrame.ujJatek(MainJFrame.java:57)
    at gui.MainJFrame.<init>(MainJFrame.java:29)
    at Main$1.run(Main.java:37)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:682)
    at java.awt.EventQueue$3.run(EventQueue.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

1 个答案:

答案 0 :(得分:0)

MainJFrame.slotpool为空...