View Full Version : JMenuBar with Canvas

04-03-2008, 12:13 AM
I'm making a small game and my main class extends Canvas. In my main method I construct a JMenuBar and add it to my JFrame. I then add a canvas to the JFrame using frame.getContentPane().add(myclassname). The problem is when I click on a category on my menubar it's opening up behind my canvas. Is there any way to get it to open in front of it? Thanks.

04-08-2008, 06:08 AM
The problem you're encountering is mixing lightweight(JMenuBar) and heavyweight(Canvas) components. A common issue but it's easily correctable. Use the JPopupMenu.setLightWeightPopupEnabled() method. Here's a link with a more in depth description of the problem.