JOGL and JMenu?

I have a small problem, I am using JOGL with Swing, and have a JMenuBar and a JOGL context, but my problem is the JOGL context places itself in front of the menu when it drops down. Is this a known JOGL bug, or is it something else? It works with regular MenuBar, and I have tried to set the Z-order, but to no avail. Does anyone have any ideas?

You’re trying to mix heavyweight(Canvas) with lightweight(JMenu) components, which in my book is a no no…

Read http://java.sun.com/products/jfc/tsc/articles/mixing/ for the reasons why your canvas is overlapping the JMenu components.

Here is a page i found with some quick notes of mixing Java3d canvas with swing components http://www.j3d.org/tutorials/quick_fix/swing.html.

Regards,

Ribot

Ahh, thanks alot! that did the trick =)

another question along this line:

this works fine with JMenu (or other lightweight
popups), but how about the drop down menu
of a window. (I don’t remember the right term for
it, but the one appears when you click on the icon
at the top-left corner of a window.) I don’t seem
to find a way to make it appear on top of the
GLCanvas. Any idea?

okay, I guess I got this right.

I had the line

JPopupMenu.setDefaultLightWeightPopupEnabled(false);

before the line (before instantiating the frame),

jframe = new JFrame();

But I switched the order (i.e., instantiate the frame
after setting the lightweight stuff), then it works!

There’s an easy way to make your menu heavyweight 8)

For example:


JMenuBar menuBar;
JMenu myMenu;

myMenu = new JMenu("test...");
myMenu.add(new JMenuItem("subItem..."));
myMenu.getPopupMenu().setLightWeightPopupEnabled(false);
menuBar = new JMenuBar();
setJMenuBar(menuBar);

I hope this helps :wink: I’ve spent a lot of time to find this, and now I can see a JMenu over a Canvas ;D (sorry for any mispelings here, I’m at hurry and English isn’t my native language!)

[]'s

Peter