We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So, I'm using Processing in a swing app and I'm wondering if there is a way to stop a JFrame from closing after the Processing sketch is stopped. This code will demonstrate my problem:
JFrameTest.pde
Frame frame;
void setup(){
frame = new Frame();
size(300, 300);
}
void draw(){
}
Frame.pde
import javax.swing.*;
class Frame extends JFrame {
public Frame(){
super("Panel");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(250, 250);
this.setResizable(false);
this.setVisible( true );
}
}
I understand that in this case, Frame is a nested class of JFrameTest in Java. In my app, this isn't the case. I use the PApplet.main method to start Processing sketches but I'm curious if there is a solution from with the PDE!
Answers
https://Forum.Processing.org/two/discussions/tagged?Tag=setdefaultcloseoperation()
Thanks for pointing me to that, @GoToLoop.
In case anyone is curious, this is what the file should look like!
JFrameTest.pde
Thanks, @quark!
Is that proper? If I close the Frame object, it crashes. If I close the sketch, then the frame, you get a nasty messages: dead thread. Wouldn't one override their exit functions? Now, you might have re-defined your Frame class to handle the current sketch.
Kf