www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Dominic2 on January 22, 2009, 08:32:03 pm

Title: JMenuBar menu's are hidden by OpenGL canvas
Post by: Dominic2 on January 22, 2009, 08:32:03 pm
Hi,

I'm trying to put a JMenuBar in my application window. The menu bar itself is displayed correctly. Unfortunatly, the menus that appear when the user click on a menu of the menu bar are hidden by the OpenGL canvas in the window. The canvas is always rendered on top of the menus.

I use the OpenGL renderer only. I use

Code: [Select]
frameBuffer.enableGLCanvasRenderer(IRenderer.MODE_OPENGL);
to initialise the OpenGL renderer and then I disable the software renderer. When rendering, I use the following code :

Code: [Select]
        frameBuffer.clear();
        world.renderScene(frameBuffer);
        world.draw(frameBuffer);
        frameBuffer.update();
        frameBuffer.display(graphics);
        canvas.repaint();

Is there something I can change to allow the menu to be displayed correctly ?

Thank you for your help.
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: EgonOlsen on January 22, 2009, 09:08:27 pm
The  GL-canvas is a heavy-weight component. Might be that the menu is light-weight...i'm not a Swing-guy, but i think it is. IIRC, there is some way to force light-weight components to be heavy-weight. Maybe the lwjgl-forum at http://lwjgl.org (http://lwjgl.org) has some more info about this issue.
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: EgonOlsen on January 22, 2009, 09:16:29 pm
Like here: http://lwjgl.org/forum/index.php/topic,2450.0.html (http://lwjgl.org/forum/index.php/topic,2450.0.html)
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: paulscode on January 22, 2009, 10:58:34 pm
I had the same issue a while back, but never found a desireable solution (I kept having flicker issues).  If you ever figure this out, let me know.
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: Dominic2 on January 28, 2009, 06:01:48 pm
I found a solution. Swing purists are not going to like it, but it works for me. I use Menu (from awt) instead of JMenu (from swing). Menu use the OS's menu bar and this one isn't displayed under the 3D view.
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: influt on January 28, 2009, 06:33:15 pm
you could also try
JPopupMenu.setDefaultLightWeightPopupEnabled(aFlag)
but it works only for popups, other swing components won't display over the GL window correctly
Title: Re: JMenuBar menu's are hidden by OpenGL canvas
Post by: paulscode on January 29, 2009, 03:24:13 am
Yeh, I was more interested in other Swing components than the JMenu.  It is good to know that at least Menu will work, though.