Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JMenuBar with Canvas

    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.

  • #2
    New Coder
    Join Date
    Jun 2005
    Posts
    32
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •