Hi, I’m trying to save data when my app close either with mouse or ESC button.
I try with exit() and stop() with any result.
this is my code
void stop(){
saveSlides();
exit();
}
Thanks
Hi, I’m trying to save data when my app close either with mouse or ESC button.
I try with exit() and stop() with any result.
this is my code
void stop(){
saveSlides();
exit();
}
Thanks
I think stop() is deprecated
have a look at addShutdownHook()
try adding this in the setup()
// called upon program termination
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
saveSlides();
}
}
);
Thank you a lot. It works perfect
great! glad it helped
The Processing method your looking for is dispose()
:
@Override
public void dispose() {
println("Print this when sketch is closed.");
}
It seems as if stop()
if called only when an applet runs in a web browser (which isn’t possible anymore anyway!)
Called by the browser or applet viewer to informthis applet that it should stop its execution.
Unfortunately, there are no guarantees from the Java specwhen or if stop() will be called (i.e. on browser quit,or when moving between web pages), and it's not always called.
I tried with dispose() but when I click on the cross the function run but the sketch doesn’t close. Thanks for help
Interesting. Try this then:
public void dispose() {
println("Print this when sketch is closed.");
super.dispose();
}
Now it’s ok, great !