aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Add component above JFrame's menubar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Add component above JFrame Watch "Add component above JFrame New topic
Author

Add component above JFrame's menubar

Sean O'Donnell
Greenhorn

Joined: Dec 27, 2005
Posts: 12
Is it possible to add a component (e.g. a JPanel representing a banner) above the menubar in a frame, but below the header/title bar? If so, could you please point me in the right direction.

Thanks!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

please point me in the right direction.


-------> The API for JRootPane


luck, db
There are no new questions, but there may be new answers.
Sean O'Donnell
Greenhorn

Joined: Dec 27, 2005
Posts: 12
Okay, so I need to replace the LayoutManager, thanks!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
Darryl's solution is probably the proper solution but it is more involved than just changing the layout manager. You would also need to create a custom JRootPane which would need to be added to the frame. It would need methods like addBanner(...), getBanner(...).


Another approach might be to just add the menubar directly to the content pane:

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Another approach might be to just add the menubar directly to the content pane:

I was thinking more in terms of using a JMenuBar as a header and nesting another JRootPane.This approach could of course benefit from extending JFrame to get a class that forwards add/remove/setLayout/getLayout to the inner root pane's contentPane.

Yet another approach (almost the same as yours) could be to nest the banner and menu bar in a JMenuBar with GridLayout(0, 1) or BoxLayout.VERTICAL or ...
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
Yes, I think I like the NestedMenuBar approach better.

I think its better than playing around with the root pane.

It doesn't mess up the content pane like my solution does.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add component above JFrame's menubar