Jump to content
  • Advertisement
Sign in to follow this  
Funkyjive

[java] JOGL covering menubar

This topic is 3533 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!