...

View Full Version : JMenuBar with Canvas



sharp65
04-02-2008, 11:13 PM
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.

icm9768
04-08-2008, 05: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.

http://exampledepot.com/egs/javax.swing/PopupHw.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum