We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › PApplet with other Swing/Awt Panels
Page Index Toggle Pages: 1
PApplet with other Swing/Awt Panels (Read 2229 times)
PApplet with other Swing/Awt Panels
Mar 31st, 2006, 1:21am
 
(I'm not sure if this is the same question as the earlier multi-window question or not but here goes)

I want to have some GUI controllers available for my Processing program.  Typically one does this by creating a JFrame then two JPanels, one for processing's Drawing panel, one for the GUI panel that modifies the parameters to the running processing program.

I've noticed the conversation on MyGUI and other ways to control the PApplet using widgets right in the PApplet panel/canvas.  But I doubt this will work for me due to using 3D with rotations and so on.

Here's an example:
 http://backspaces.net/models/GraphViz/applet/

I'd like to replace all the keyboard commands with buttons, sliders etc in a separate panel.  I'm concerned that using P3D and OPENGL window types will cause weirdness like rotation of the widgets!

So the question is: can I have the PApplet in its own Panel with a separate GUI panel next to it somehow?  I.e. a JFrame + two panels, one for Processing, one for the associated GUI widgets.

Thanks!

Owen
Re: PApplet with other Swing/Awt Panels
Reply #1 - Apr 2nd, 2006, 1:00am
 
Hi Owen,

I'd love for MyGUI to work 'ontop' of 3D applets, haven't had the time to make them compatable yet.

A note on the interface I saw you used z and x keys with the mouse, maybe you could consider an alternative (3 mouse button) interface:
http://mkv25.net/applets/brickBuilder/

As for using a separate panel, surely its possible. I saw one thing where you use Flash to control a Java applet via javascript, so it must be possible to control another Java applet using javascript.

Maybe look at the javascript library that comes with processing.

Regards,
- Markavian
Re: PApplet with other Swing/Awt Panels
Reply #2 - Apr 4th, 2006, 12:14am
 
Hi Markavian -- thanks for the pointers.

Owen
Re: PApplet with other Swing/Awt Panels
Reply #3 - Apr 4th, 2006, 7:17pm
 
Just to be a bit clearer -- what I think this requires is simple:

PApplet be implimented via a PPanel which contains most of PApplet so that we can use Processing in its own Panel with additional GUI elements etc in a separate panel, controlling the PPanel.

Owen
Re: PApplet with other Swing/Awt Panels
Reply #4 - Apr 4th, 2006, 8:03pm
 
it's simpler than that, an applet is just a component and you can add it to a swing layout the way you would any other awt component. as of recent releases, PApplet handles resizing itself properly when the layout manager asks it to.

noLoop() and redraw() are important in these situations, so that you don't have several animation threads running that need not be, and so that they aren't fighting with each other.
Re: PApplet with other Swing/Awt Panels
Reply #5 - Apr 5th, 2006, 1:33am
 
Good suggestion -- I'll see if I can make a swing control panel work with PApplet using your directions.

BTW: I'd just like to say a very warm thank you for this incredible project.  We're working on some visualization projects for our clients (We're http://redfish.com), so we built a really demanding stress test: a general spring layout graph with universal repulsion (i.e. n-squared computation) between each node.  We tried several graph types, one with fairly heavy constraints.  And then we put "events" on each edge which travel smoothly up/down between the edge nodes.

I honestly thought this would grind to a halt, and we'd have to make movies out of the model for reasonable speeds.  Well, I was dead wrong, Processing just did an unbelievably stunning job of the task!

Here is a pointer to the GraphVis applet.
 http://backspaces.net/models/GraphViz/applet

And here is a tarball for downloading.
 http://backspaces.net/files/GraphViz.tar.gz

This was done in roughly 2.5 work days.  Really fine, thanks again!

Owen
Re: PApplet with other Swing/Awt Panels
Reply #6 - Aug 11th, 2006, 10:40pm
 

Hey Fry.

I'm interested in this: (quoting yourself just above)
"
it's simpler than that, an applet is just a component and you can add it to a swing layout the way you would any other awt component. as of recent releases, PApplet handles resizing itself properly when the layout manager asks it to.

noLoop() and redraw() are important in these situations, so that you don't have several animation threads running that need not be, and so that they aren't fighting with each other."

I'd like to add a processing applet into a Swing GUI with all the Swing buttons and sliders, etc. What do you mean by noLoop() and redraw() being important?

Should one skip them and let the Swing do the looping/redrawing?
Do you have to send messages to the PApplet or is this automatic?

Could you clarify this better, please?

cheers
Page Index Toggle Pages: 1