Sign in to follow this  

[java] JOGL covering menubar

This topic is 3319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello again. I am having problems with implementing openGL into a java game. The problem comes when trying to add both a MenuBar and an opengl drawing area to a JFrame. It works and renders ok, but when I click one of the options in the menu the drop down list renders under the opengl region and I can't see the options. Here is the code for setting up the window...
    frame = new JFrame("Robot Game");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
    GLCanvas canvas = new GLCanvas();
    canvas.addGLEventListener(new OpenGLViewer());
    frame.add(canvas);
    frame.setSize(800, 600);
    frame.setVisible(true);
		
    Menu menuBar = new Menu();
    frame.setJMenuBar(menuBar);
		

    frame.setVisible(true);
    frame.setResizable(false);
I am using JOGL for the gl bindings. Any ideas of what is going on? Thank you, FunkyJive

Share this post


Link to post
Share on other sites
Found a solution.
<code>
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
</code>
Found that after googling around. Not realy sure what it's doing but it fixes the problem. Im assuming the drop down list is of type JPopupMenu so that is why altering the parameter fixes it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Funkyjive
Not realy sure what it's doing but it fixes the problem.


The root of your problem is mixing heavyweight and lightweight components. AWT components are (mostly) heavyweight while Swing components are (mostly) lightweight. The difference is whether or not the component uses resources from the underlying OS API. For example, dig around inside of the Windows AWT code and you'll find that any AWT window will have an associated window handle from the Win32 API. Swing components are (mostly) independent of the OS.

The GLCanvas is a heavyweight component, since it descends from the AWT Canvas class. When using it with Swing components, you need to be aware of the problems that can arise when mixing heavyweight and lightweight components in the same UI. There's an article at Sun that explains it well enough.

Share this post


Link to post
Share on other sites

This topic is 3319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this