Only starting the main program when necessary?

I’m working on a fairly complicated project involving multiple windows using G4P - the first window is the standard processing one, and the other two are a user interface window and a real time graph.

In order for the project to work, the user has to be able to interact with the interface window (putting in data for the program to use), and then pressing a “run” button. Upon this press, the main window should start running (setup, then draw, etc).

I honestly don’t know how to get this to work even in concept - as far as I know, the only way to start running processing code is from the main setup function, but this contains code that requires data the user should input from the other window… which as far as I know, can only be launched from the main setup code - agh!

Effectively, I’m stuck. I’m not sure how to get this working at all, and I really don’t have time to rebuild and restructure the entire project. Is there a way to say “only start running setup and draw once this thing has happened”?

1 Like

Sure, you could use Processing as a Java library and only instantiate the sketch class when your criteria has been met.

Shameless self-promotion: here is a guide on using Processing as a Java library:

3 Likes

You can hide the Processing’s main window and pause it w/: :dark_sunglasses:

getSurface().setVisible(false);
noLoop();

In order to show it and resume the window: :running_man:

getSurface().setVisible(true);
loop();
3 Likes

For this project I doubt I’ll have time for a rethink of those proportions - however, I will keep it in mind for later projects, using Processing in that way seems super extensible and useful. Thanks a lot for the tutorial + link, it’ll help me out a lot.

Thanks a lot, I’ll see if I can implement this