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 › Menus drawn under PApplet
Page Index Toggle Pages: 1
Menus drawn under PApplet (Read 1229 times)
Menus drawn under PApplet
Jun 18th, 2008, 1:57pm
 
Hi,
i embedded a PApplet inside a custom application, but the menus of my application are drawn under the PApplet, and can't be clicked.

Anyone has an idea on how i can repair that?
Re: Menus drawn under PApplet
Reply #1 - Jun 20th, 2008, 10:26am
 
what kind of application? a Swing interface?
Re: Menus drawn under PApplet
Reply #2 - Jun 20th, 2008, 11:08am
 
the basic idea is that you can call methods from a menu that will draw things in the applet (kind of like a Gimp based on processing).

The hosting application is made using Swing, the menu bar is a JMenuBar, containing "JMenu"s and "JMenuItem"s.

You can see below what the application looks like, the big Grey area is the Processing Frame (using the code given in the PApplet doc).  
...

here is the code I use to embbed the applet :

Code:

mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));

appletView = new EmbeddedApplet();
appletView .setMinimumSize(new Dimension(640,480));
appletView .setMaximumSize(new Dimension(640,480));
appletView .setPreferredSize(new Dimension(640,480));
appletView .init();

mainPanel.add(artspaceView);


and my EmbeddedApplet class :

Code:

public class EmbeddedApplet extends PApplet {


public void setup() {
size(640, 480);
noLoop();
}


public void draw() {
// apply things in the command queue
}


public void mousePressed() {
// do something based on mouse movement
redraw();
}
}
Re: Menus drawn under PApplet
Reply #3 - Jul 6th, 2008, 3:51pm
 
You could just make menus in your pApplet and skip out the embedding thing you've got going on.

have a look at this;

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1214314785;start=1#1
Re: Menus drawn under PApplet
Reply #4 - Jul 6th, 2008, 10:51pm
 
well instead of that i used a frame especially for the processing rendering, and another one for the rest of the GUi (kind of Gimp Like). But anyway the processing frame is just a part of the application i'm trying to do, so i can't put the menu directly inside processing.
Re: Menus drawn under PApplet
Reply #5 - Jul 8th, 2008, 11:22am
 
oh i see what you mean. the PApplet is always redrawn on top of other swing components. i think it's all about the order the components are drawn in the content pane. i've tried something with getContentPane().getComponentZOrder() but couldn't get the expected result... arg!
Page Index Toggle Pages: 1