Hi,
When you run your code in Processing or export it as a standalone app, it is wrapped into a PApplet
class with a main
function that runs your code.
For example :
void setup() {
size(500, 500);
}
void draw() {
background(255);
circle(mouseX, mouseY, 50);
}
Becomes :
import processing.core.PApplet;
public class test_app_export extends PApplet {
public void setup() {}
public void draw() {
background(255);
circle(this.mouseX, this.mouseY, 50.0F);
}
public void settings() {
size(500, 500);
}
public static void main(String[] passedArgs) {
String[] appletArgs = { "test_app_export" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
So closing the PApplet means closing your application
One solution is to run another PApplet instance as described here :
But when closing one window, it closes the others. Luckily for us, micycle provided a nice workaround :
You can also stop the main PApplet instance and restart it but you’ll loose memory (you can always save it to a file) :