aspose file tools*
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 Spring in Action this week in the Spring 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: 2317
    
  49
This would be better off in the Swing forum so I have moved it for you.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2317
    
  49
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: 4642
    
    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.
 
Don't get me started about those stupid light bulbs.
 
subject: panel appears behind menubar sometimes