• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

panel appears behind menubar sometimes

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have a simple JFrame with a borderlayout. A menubar is added at North and a panel is added at centre. Most of the time it works as it should but sometimes the panel appears behind the menubar. I don't understand why this only happens sometimes. Can anyone give me some clue?

I can add the code if it's needed.
frame1.JPG
[Thumbnail for frame1.JPG]
frame2.JPG
[Thumbnail for frame2.JPG]
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This would be better off in the Swing forum so I have moved it for you.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Al Finlay wrote:Hi. I have a simple JFrame with a borderlayout. A menubar is added at North and a panel is added at centre.


Menu bars shouldn't be added to a panel they should be added to the JFrame using the setJMenuBar() method.
 
Al Finlay
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually had added the menubar to the frame not the panel using



but when I changed it to



the bug disappeared. Thank you so much!
Any idea why the setJMenuBar() method is more reliable?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the API for JRootPane to understand better. If you don't know where JRootPane comes into the picture, check the APIs of interfaces implemented by JFrame.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic