This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes panel appears behind menubar sometimes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "panel appears behind menubar sometimes" Watch "panel appears behind menubar sometimes" New topic
Author

panel appears behind menubar sometimes

Al Finlay
Greenhorn

Joined: Oct 26, 2012
Posts: 16
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.


[Thumbnail for frame1.JPG]

[Thumbnail for frame2.JPG]

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2176
    
  47
This would be better off in the Swing forum so I have moved it for you.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2176
    
  47
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
Greenhorn

Joined: Oct 26, 2012
Posts: 16
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

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
 
Consider Paul's rocket mass heater.
 
subject: panel appears behind menubar sometimes
 
Similar Threads
menu bar is not visible when designing
Drawing
AWT Container
Can I add menubar in a panel
Menu problem