We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Any time I try to call exit() from settings(), it will cause a NullPointerException. It will work fine if I call it from anywhere else. Any idea of why? or how to fix it?
Answers
OK, now I am curious: why are you calling exit() in settings()? This method is to call some specific functions, not to have any logic in it (AFAIK), and if you call exit() there, your sketch just stops. So I fail to see the use case.
I was pulling user input from a JOptionPane.showInputDialog in settings so that I could make the screen the size of inputted integers, and I wanted to be able to exit if the user pressed cancel.
Create a boolean variable
doExit
then insettings()
test the value returned from JOptionPane and set a the value ofdoEvxit
accordingly. In setup testdoExit
and callexit()
if true.That way you avoid calling
exit()
insettings
Thank you so much. I don't know why I didn't think to do that. I have done that in other programs, but I just hadn't thought of that for some reason. Thanks again.