Forums Register Login

Add component above JFrame's menubar

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
 

please point me in the right direction.



-------> The API for JRootPane
+Pie Number of slices to send: Send
Okay, so I need to replace the LayoutManager, thanks!
+Pie Number of slices to send: Send
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:

+Pie Number of slices to send: Send
 

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 ...
+Pie Number of slices to send: Send
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.
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 6460 times.
Similar Threads
Please help me work on my "Swing"
Jxam question on Frame and menubar
Menu Question
JLabel.setbounds method not working.
Swing Web Browser problems
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:47:00.