We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm using Processing under Eclipse, and I have two sketches that would be loaded in two different JPanel inside a JFrame. I need to fire custom events from each sketch to be handled in another class. I'm using the EventObject and the EventListener model. Thanks.
Answers
Do you really need events? Or are you just trying to call a method in one sketch from the other?
I'm thinking in events, maybe it can be done in other way. What I need is to notify to the "sketch loader", that one sketch ended successfully (or with error), and to try to reload or load the other sketch according to this. Thanks.
Either way, you need to pass some references around. You either need to pass your main class into each sketch, or pass the sketches to one another. You would do this via setter functions.
Quick & dirty solution. Declare a
boolean
static field and @Override exit() to set it totrue
: :ar!Dirty is right. This is a misuse of the static keyword, and I wouldn't recommend it.
A more elaborate callback hack:
static
method inside PAppletIgniter which is called back by some PApplet instance when it's exit()ed!"PAppletIgniter.java":
"Sketch.java":
Gross. Why not just use Objects the way they're intended?
PAppletIgniter.java:
Sketch.java:
Thanks for your answers, I'll give it a try and post the results here.