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 and GridBaglayout
Page Index Toggle Pages: 1
PApplet and GridBaglayout (Read 1049 times)
PApplet and GridBaglayout
Nov 11th, 2005, 3:10pm
 
Hello,
The problem i am facing while using PApplet is that i cannot seem to able to use it with a layout manager.
I am trying to avoid setting size of PApplet container myself. The reasons are obvious namely

I do not want to recalculate relative position and size of PApplet component on every window resize event. I would like the layout manager in swing to do it for me.

So what i did was to create a JFrame with a bunch of JPanels in them, with the frame layout as gridbag.
Then i proceeded to change one JPanel type to PApplet. Change background color was happy to see the background of the entire former JPanel change.
But the moment i try to draw on the PApplet component, it defaults to a size of 100,100.

Is there any code examples using Papplet with swing namely in a layout framework where size() function is not used and the layout manager calculates the size?

thank you,
Sameer
Re: PApplet and GridBaglayout
Reply #1 - Nov 11th, 2005, 3:25pm
 
you need to capture the event (using a ComponentListener) that happens when the applet is resized, and use that to call size() so that it updates itself properly. this is something that will be done automatically by the time 1.0 rolls around.

it's been on the todo list so i just filed a bug for it for anyone else that comes across this:
http://dev.processing.org/bugs/show_bug.cgi?id=209
Page Index Toggle Pages: 1