2

I working on a Processing program that runs in to different windows. On holds the controllers, thats the main PApplet, the other one is running some OpenGL and is a subclass of PApplet as well.

Creating an instance of the OpenGL window isn't too difficult but how do I destroy() it without calling exit() and killing the entire process. I just want to close the second window and free all it's resources.

I couldn't find any proper solution.

Jeel Shah
  • 3,274
  • 17
  • 47
  • 68
codingjoe
  • 1,210
  • 15
  • 32

1 Answers1

1

Calling PApplet.destroy() does not cause a System.exit() call on its own. Closing the Frame in which your PApplet runs, however, will. You should be able to call PApplet.destroy() to terminate the main PApplet animation thread, and then call frame.setVisible(false) to close the window without triggering a System.exit() call.

In other words, try:

destroy();
frame.setVisible(false);
ericsoco
  • 24,913
  • 29
  • 97
  • 127
  • Thanks, I initialized the frame in the *PApplet* constructor. When I disposed the *PApplet* the frame got finalized and called `System.exit()` – codingjoe Sep 23 '12 at 13:59