Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

panel appears behind menubar sometimes

 
Al Finlay
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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]
 
Tony Docherty
Bartender
Posts: 2958
59
  • Mark post as helpful
  • send pies
  • 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: 2958
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 34
  • Mark post as helpful
  • send pies
  • 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?
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic