-2

我正在尝试构建一个需要将自身传递给另一个的类,但是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)
4

1 回答 1

0

MainJFrame.slotpool一片空白...

于 2013-04-21T13:13:15.203 回答