We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I couldn't find any examples showing 2nd window close without exiting the first. Using exitActual()
seems to do the trick. Any comments on this approach versus some alternative?
Note settings()
is needed to correctly set the size(500, 500)
of the first window. Also mousePressed()
is used to reopen the window.
boolean frame2Exit;
String[] args = {"TwoFrameTest"};
SecondApplet sa;
void settings() {
size(500, 500);
}
void setup() {
frame2Start();
}
void draw() {
background(0);
ellipse(50, 50, 10, 10);
}
void mousePressed() {
if (frame2Exit)
{
frame2Start();
}
}
void frame2Start() {
sa = new SecondApplet();
PApplet.runSketch(args, sa);
frame2Exit = false;
}
public class SecondApplet extends PApplet {
public void settings() {
size(300, 300);
}
public void draw() {
background(255);
fill(0);
ellipse(100, 50, 10, 10);
}
public void exitActual() {
frame2Exit = true;
}
}