Response title
This is preview!




Click on Join Now to Sign Up
Yes you're right.
I was under the impression that stop() always gets called by the applet so there isn't any need to test for ESC etc.
/**
* Call to safely exit the sketch when finished. For instance,
* to render a single frame, save it, and quit.
*/
public void exit() {
if (thread == null) {
// exit immediately, stop() has already been called,
// meaning that the main thread has long since exited
exit2();
} else if (looping) {
// stop() will be called as the thread exits
finished = true;
// tell the code to call exit2() to do a System.exit()
// once the next draw() has completed
exitCalled = true;
} else if (!looping) {
// if not looping, need to call stop explicitly,
// because the main thread will be sleeping
stop();
// now get out
exit2();
}
}
// if someone else wants to intercept the key, they shouldBut i'm not sure that calling stop() would close audio buffers.
// set key to zero (or something besides the ESC).
if (event.getID() == KeyEvent.KEY_PRESSED) {
if (key == KeyEvent.VK_ESCAPE) {
exit();
}