I am currently having some trouble on display errors. When an error occurs, it is called from a method in another class.
public void foomethod(Foo foo, Fuu fuu) {
if(foo.getMethod() == 0) {
if(engine.placeMethod(foo, fuu) == true) {
foo_view.removeCurrentError();
engine.rollFoo(foo, frame.getInitialDelay(), frame.getFinalDelay(), frame.getDelayIncrement());
}
else {
foo.placeMethod(0);
}
}
else {
foo_view.displayCurrentError("Foo has already placed a method");
}
}
And this is the thread
@Override
public void actionPerformed(ActionEvent e) {
new Thread() {
@Override
public void run() {
try {
int fuu = Integer.parseInt(frame.getGameView().getFooView().getMethod());
Foo bet_foo = frame.getGameView().getFooView().getFoo();
foomethod(bet_foo, fuu);
} catch (NumberFormatException excpetion) {
System.err.println("fuu is not an integer");
}
}
}.start();
}
The error it displays is
Exception in thread "Thread-3" java.lang.NullPointerException
at controller.FooListener.rollFooDice(FooListener.java:31) <-- this is foo_view.removeCurrentError();
at controller.FooListener$1.run(FooListener.java:57) <-- this is .start();
The problem is when I call foo_view.removeCurrentError();
the error shows up and the error display shows the same exception.