谷歌搜索了很多,我没有发现这个特定类的问题Key.Adapter.class
(rt.jar
插件 Java Source Attacher(不起作用)。我也重新安装了Eclipse,但仍然出现错误:
奇怪的是,我没有对与库相关的任何内容进行任何更改(如果我这样做了,那不是故意的)。我只是在移动一些东西,但与图书馆无关。控制台在第 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);
}
}
}
}
);
做一个新项目也是如此。并且窗口设计器/运行也不能正常工作。
还有另一种可能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)