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 › embed my PApplet versus use SpringGUI in my applet
Page Index Toggle Pages: 1
embed my PApplet versus use SpringGUI in my applet (Read 860 times)
embed my PApplet versus use SpringGUI in my applet
Jul 8th, 2008, 10:47pm
 
I'm trying to give my processing applet a good user interface with buttons and such.  I have gotten two ways to work:

1. Download the SpringGUI in the libraries section and use these GUI elements in a PApplet
2. Create a subclass of java.awt.Frame which simply embeds my PApplet into it

I know that with option 2 some of my event listener methods will be in my Frame subclass and others will be in my PApplet subclass, whereas in option 1 they can probably be consolidated in the one PApplet subclass.

Anyone with GUI-making experience know which choice may be wiser (perhaps as far as performance/compatibility...other stuff).

...It does appear that the embedding option may eliminate some features of the processing applet...
Re: embed my PApplet versus use SpringGUI in my ap
Reply #1 - Jul 9th, 2008, 6:21pm
 
well... both choices may lead to unexpected result.

option 1: there may be fundamental issues on some platforms
Quote:
You can use SpringGUI to add GUI elements to both Processing applets and Processing applications, but you should be aware that a fraction of your online audience might not get what you expect.

option 2: you might get unexpected results too, see for example
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1213790241

i think option 2 can make sense if you want to separate the menu and the rendering pane. from what i've tried, i would say that it's working well (unless you want to use a menu bar, then be prepared to face this annoying and unsolved always-on-top problem).
Re: embed my PApplet versus use SpringGUI in my ap
Reply #2 - Jul 9th, 2008, 8:41pm
 
I decided finally to use NetBeans6.1 to create a SwingGUI, and I got frustrated by that untouchable generated code.  But I was able to embed my PApplet into the GUI by adding a JPanel (named appletPanel) then in a part of the code that I CAN edit:
...
MyPApplet p = new MyPApplet();  
           
p.init();

appletPanel.add(p);
...

Of course, this gives me the problem of GUI getting drawn underneath my PApplet (will be a problem for tooltips/internal frames/popups), but I shall find a cure!
Re: embed my PApplet versus use SpringGUI in my ap
Reply #3 - Jul 10th, 2008, 8:40am
 
Quote:
I got frustrated by that untouchable generated code

You still can edit that code : RMB > Customize Code on your JPanel for example. But you've done it the right way, anyway.

Please share your 'cure' with us, if you find a solution to the problem above!! :-)
Page Index Toggle Pages: 1