We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I hope to be able to update G4P for Processing 3. One of the key features of G4P was the ability to create apps with multiple windows. This was straightforward with PS2 because Applet inherited from PApplet, a windowed component.
I have been looking through PS source code but I have not found an obvious way of doing this.
Any hints or ideas gratefully received.
Thanks
Comments
Already tipped you about it before... Have you looked at runSketch() already?
It exists since Processing 1. And "ignites" any PApplet instance w/ its own "canvas" + "Animation" Thread.
http://forum.Processing.org/two/discussions/tagged?Tag=papplet.runsketch()
This just came up on StackOverflow earlier today: http://stackoverflow.com/questions/32243316/new-window-in-processing
Here's my slightly hackish answer:
This works for me, but I'm not sure how stable it is.
@GoToLoop sorry about that, forgot you mentioned it earlier
@KevinWorkman thanks for the example of using runSketch
This is brilliant I can see there will be other issues such as setting the frame name (Java mode) but it is a good start.
Thanks guys
You can still get to the frame variable, as discussed here: http://forum.processing.org/two/discussion/12260/processing-3-init-disappearance#latest
But you probably don't need to do that. Just go through the new
surface
variable:surface.setTitle("Your Title Here");
For backwards compatibility, you can make frame field an alias for surface or vice-versa. O:-)
Thanks again guys.
No, you can't. The
surface
variable is of typeprocessing.core.PSurface
. Theframe
variable is of typejava.awt.Frame
. They are incompatible types, since they don't share an inheritance, so they can't be assigned to one another.Backwards compatability will not be possible because the differences between PS2 & PS3 are too great.
Yesterday I released G4P V3.5.4 as the last version compatible for PS 2.2.1 all future releases will target PS3
I'm not sure what you're trying to prove with that code, but that's a horrible misuse of reflection- and it won't work with Processing.js at all.
That code does not create an alias between
surface
andframe
. It simply callsframe.setTitle()
, which you can (and should) just do directly:Or better yet, just go through the
surface
variable like you're supposed to:If you think your code is doing something useful, please post an explanation. I'm still learning how Processing 3 fits together, so I'd love to learn more about it.
https://GitHub.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L10313
protected
.getClass().getField("surface");
fails! :-&getClass().getSuperclass().getDeclaredField("surface");
instead. 3:-OP.S.: Actually what's stored in Processing 3's frame field is a fake Frame class; not the true java.awt.Frame or javax.swing.JFrame 1s! ~:>
If it wasn't clear enough, I'm just trying to prove we can make some code dynamically choose either frame or surface fields depending on Processing's version it's running upon!
Therefore, it's entirely possible for @quark to make newer versions of his G4P library to run both on Processing 2 & 3. Perhaps even on Processing 1! O:-)
The example I've posted above runs in any Processing version.
And invoke()s method setTitle() either over a processing.core.PSurface or a java.awt.Frame object! \m/
Dunno why you've brought pjs framework as an issue here! 8-|
G4P library isn't cross-mode & neither JS language needs any "reflection" techniques! [-(
And if that's indeed a "reflection" misuse, can you tell us how to do all of that w/o it? :O)
A slightly shorter variant relying on isAssignableFrom() in order to determine which Field to get: :D
Sorry that is a totaly unrealistic expectation.
Although from the users perspective G4P looks the same thats only because the API changes little between versions of Processing. G4P hooks into Processings inner workings so there is not a chance in hell of getting a single version of G4P to work on both PS2 & PS3, just as there was no chance with PS1 & PS2