I am creating a KeyEvent for my Main class, what I want the event to do is when the UP key is pressed, it will return n as false, and when the DOWN key is pressed, it will return n as true.
package main;
import java.awt.event.KeyEvent;
public class IsStopped {
public static boolean main(String[] args, KeyEvent e) {
boolean n = false;
int key = e.getKeyCode();
if (key == KeyEvent.VK_UP) {
return n = false;
}
if (key == KeyEvent.VK_DOWN) {
return n = true;
}
return n;
}
}
I want to use n for my Main class. Like this inside a loop:
if(main.IsStopped.main(args, null) == false) {
break;
This is what returns once I run my Main class:
Exception in thread "main" java.lang.NullPointerException at main.IsStopped.main(IsStopped.java:12) at main.Main.main(Main.java:27)
How would I define e?