Opening and closing extra window

This is my second time asking. The previous time I was unclear about what I wanted, however, it was still useful, so I don’t want to delete it.

I want to be able to create an extra window, within the same sketch and make it fully interactive with the previous one (the first one will be the command center, that will order things to appear or the second). The window should be resizable (surface.setResizable(true)) and if possible able to appear and disappear with a single function (for a different project I am working on).

If you can please give me a bare-bones code so I can improve it (I have both sides programmed, I just need to add the second window for it to be finished)

I have tried a few times but still failed. I hope you can help me with that.

Thanks

Forum.Processing.org/two/discussion/16457/size-method-for-intial-window-not-working-when-more-windows-are-are-added#Item_1

2 Likes

but why do you need extra sketches if you have everything hereimage ?

That link is for a demo that contains 1 main sketch which creates 2 extra sketches.

Each sketch is a PApplet subclass which is ignited by runSketch().

but can they communicate with eachother?
Like setting variables that the other window uses?
But if it ignites another sketch why do you need the

static class ThirdApple...
     void settings() {
         size(400,400)
     }
     void draw() {

     }

if the other skectch must include it anyways

Yes, via their respective fields sa & ta:

final SecondApplet sa = new SecondApplet();
final ThirdApplet  ta = new ThirdApplet();

However b/c Processing isn’t threaded-safe we can’t directly call “drawing”-type methods outside their own PApplet.

Methods settings() & setup() are PApplet initializer callback methods.

That’s how a PApplet subclass works, via its callback methods.

but do settings & setup functions have to be the same as in the original sketch?

  • They do whatever we put inside them!
  • Each PApplet has its own canvas, threads and callbacks.
  • That link is just a very simple & lazy sketch example demoing 1 main PApplet + 2 extra PApplet instances.