I’m experimenting with launching multiple processing windows.
I find that when I set the renderer to be the same for all sketch instances, closing one immediately closes the other two instances.
When all renderers are different (as per the code example) the behavior changes: when the FX2D
sketch is closed, the others remain open; when the JAVA2D
sketch is closed, the other two freeze for a moment and then both close; when the P2D
sketch is closed, the JAVA2D
sketch closes immediately followed by the FX2D
sketch very shortly afterwards.
This behavior seems to be independent of the order in which the sketches (the renderers) are launched using runSketch()
.
I want the program to behave such that closing any sketch (window) does not affect the others (they will not also close). Can this be done?
This is the code I’m playing with:
public static void main(String[] args) {
Sketch sketch1 = new Sketch(PApplet.FX2D);
Sketch sketch2 = new Sketch(PApplet.P2D);
Sketch sketch3 = new Sketch(PApplet.JAVA2D);
PApplet.runSketch(new String[] { "--location=760,0", "" }, sketch1);
PApplet.runSketch(new String[] { "--location=760,80", "" }, sketch2);
PApplet.runSketch(new String[] { "--location=760,160", "" }, sketch3);
}
The Sketch
class has the following code (the renderer is set during initialization):
public final class Sketch extends PApplet {
private final String renderer;
public Sketch(String renderer) {
this.renderer = renderer;
}
@Override
public void settings() {
size(800, 800, renderer);
}
.
.
.