| 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: 4167
|
|
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: 1791
|
|
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: 4167
|
|
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: 1791
|
|
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.
|
 |
 |
|
|
subject: Add component above JFrame's menubar
|
|
|