Googling a lot, I found nothing about the problem with this specific class (Key.Adapter.class
), but there are a lot of topics about rt.jar
of course, and I tried so many things to correct it, I tried to set the location of rt.jar and installed the plugin Java Source Attacher (didn't work). I reinstalled Eclipse as well, but the error still occurs:
What's strange about this is that I didn't make any change at anything related to the library (if I did, that was not intentional). I was just moving some things but nothing related to the libraries. The console returns NullPointerException at line 190:
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);
}
}
}
}
);
To make a new project will be that way as well. And the Window Designer / Run doesn't work as well.
Is there another possibility to make rt.jar
useful again?
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)