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 › JMenu not working in JFrame containing PApplet
Page Index Toggle Pages: 1
JMenu not working in JFrame containing PApplet (Read 3324 times)
JMenu not working in JFrame containing PApplet
Mar 16th, 2007, 12:33pm
 
Hi
I am using PApplet in Jpanel that is in JFrame window.
The JPanel with PApplet is the only component in the JFrame, except that JFrame has also a JMenuBar containig JMenu with few JMenuIntems.
The JMenuBar is ok, but the JMenu is not showing, it is "hiden under" the PApplet.. I can see the edges (of the Items) on top and left. It is simply somehow under the "layer" with PApplet..

I would be thankful for any hints how to fix it.
Re: JMenu not working in JFrame containing PApplet
Reply #1 - Mar 16th, 2007, 2:10pm
 
I figured it out.

It was problem between Swing (Menu) and AWT (PApplet) components because of their different behavior.

http://java.sun.com/products/jfc/tsc/articles/mixing/

So I replaced my swing JMenu by AWT Menu and it works fine.
Re: JMenu not working in JFrame containing PApplet
Reply #2 - Oct 9th, 2009, 1:28pm
 
Actually, you don't need to replace JMenu with AWT ones. As from the article you linked you can make JMenu a heavyweight component by calling this before creating the menu:

JPopupMenu.setDefaultLightWeightPopupEnabled(false)

It boggles my mind why the swing developers decided that JMenu shouldn't be heavy weight by default. Normally you do want a menu to show on top of everything in a window regardless of any compatibility issue.

Re: JMenu not working in JFrame containing PApplet
Reply #3 - Oct 10th, 2009, 1:50am
 
Quote:
It boggles my mind why the swing developers decided that JMenu shouldn't be heavy weight by default.

Because Swing is about making everything lightweight? It is unusual to mix lightweight and heavyweight components, anyway. Making the menu heavyweight by default would result in strange look if some look & feel was used.
Beside, I think that in recent JREs, the problem is fixed.
Re: JMenu not working in JFrame containing PApplet
Reply #4 - Oct 14th, 2009, 3:22am
 
Naw, I ran into this problem when mixing a PApplet together with Swing JMenu. I'm using JRE 6, which is at time of writing as "recent" as you can get, and it isn't "fixed".  Wink
Re: JMenu not working in JFrame containing PApplet
Reply #5 - Oct 14th, 2009, 4:19am
 
Quote:
JRE 6
Not very precise (neither was I...). IIRC, it was fixed in JRE 1.6.0_10 or _12
I admit I haven't tried...
Re: JMenu not working in JFrame containing PApplet
Reply #6 - Oct 14th, 2009, 4:32am
 
Well, if it worked then it must've regressed as I'm using 1.6.0_16.
Page Index Toggle Pages: 1