Author Topic: JMenuBar menu's are hidden by OpenGL canvas  (Read 3956 times)

Offline Dominic2

  • byte
  • *
  • Posts: 5
    • View Profile
JMenuBar menu's are hidden by OpenGL canvas
« 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.

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: JMenuBar menu's are hidden by OpenGL canvas
« Reply #1 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 has some more info about this issue.

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: JMenuBar menu's are hidden by OpenGL canvas
« Reply #3 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.

Offline Dominic2

  • byte
  • *
  • Posts: 5
    • View Profile
Re: JMenuBar menu's are hidden by OpenGL canvas
« Reply #4 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.

Offline influt

  • byte
  • *
  • Posts: 25
    • View Profile
Re: JMenuBar menu's are hidden by OpenGL canvas
« Reply #5 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

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: JMenuBar menu's are hidden by OpenGL canvas
« Reply #6 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.