rt.jar / Key.Adapter.class

时间:2015-12-26 17:43:58

标签: java eclipse nullpointerexception rt.jar

谷歌搜索了很多,我没有发现这个特定类(Key.Adapter.class)的问题,但当然有很多关于rt.jar的主题,我尝试了很多东西来纠正它,我试图设置rt.jar的位置并安装插件Java Source Attacher(没有工作)。我也重新安装了Eclipse,但错误仍然存​​在:

Error Screenshot

这有什么奇怪之处在于我没有对与图书馆有关的任何事情做出任何改变(如果我这样做,那不是故意的)。我只是移动一些东西,但没有任何与图书馆有关。控制台在第190行返回NullPointerException:

name2.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent arg0) {

                int key = arg0.getKeyCode();

                if (key == KeyEvent.VK_ESCAPE) {

                    //Custom button text
                    Object[] options = {"Sim",
                                        "Não"};

                        int choice = JOptionPane.showOptionDialog(frame1,
                        "Deseja sair do jogo?",
                        "Mensagem",
                        JOptionPane.YES_NO_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE,
                        null,
                        options,
                        options[1]);

                        if (choice == 0) {

                            System.exit(0);
                }
            }
        }
        }

        );

制作新项目也是如此。 Window Designer / Run也不起作用。

还有另一种可能使rt.jar再次有用吗?

java.lang.NullPointerException
    at view.Main.<init>(Main.java:191)
    at view.Main$1.run(Main.java:49)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

0 个答案:

没有答案