Java Swing的错误 - 未知的更改

时间:2010-10-08 13:12:01

标签: java user-interface swing

我一直在研究一个基于Swing的java程序,今天我一直在编辑JComboBox(使用Netbeans所以我无法直接编辑它的代码),在编辑之间的某些时候,下面的错误有突然出现了。 显然在这一点上发布的代码太多了,但是有没有人对可能导致这种情况的任何想法/经验有什么看法?

自从此错误开始之前,我没有对源代码进行任何直接更改,但尽管已尽力撤消今天所做的所有更改,但它对这些错误没有任何影响。我甚至尝试关闭netbeans并重新启动它,因为它刚刚播放。

另外,应用程序结尾处的$ 1是多少?我以前没见过这个

感谢您提出的所有建议。

08-Oct-2010 14:07:07 org.jdesktop.application.Application $ 1 run

SEVERE: Application class nodeview.NodeViewApp failed to launch
java.lang.NullPointerException
        at nodeview.NodeViewView.<init>(NodeViewView.java:49)
        at nodeview.NodeViewApp.startup(NodeViewApp.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class nodeview.NodeViewApp failed to launch
        at org.jdesktop.application.Application$1.run(Application.java:177)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.NullPointerException
        at nodeview.NodeViewView.<init>(NodeViewView.java:49)
        at nodeview.NodeViewApp.startup(NodeViewApp.java:19)
        at org.jdesktop.application.Application$1.run(Application.java:171)
        ... 8 more

根据要求,从NodeViewView的第37行到第50行的代码

    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
        busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
            statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
        }
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
   statusAnimationLabel.setIcon(idleIcon); //49
   progressBar.setVisible(false); //50

2 个答案:

答案 0 :(得分:0)

你真的需要查看NodeViewViewNodeViewApp的代码来解决这个问题。请在这些课程中发布相关部分。

编辑:statusAnimationLabel为null然后不是它。请注意,将空值传递给setIcon(Icon icon)不会抛出NPE。

答案 1 :(得分:0)

NodeViewView.java:49是您可以找到错误的地方。大多数像对象尚未正确初始化,并且您正在尝试访问该对象的方法或成员变量。