• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Add component above JFrame's menubar

 
Sean O'Donnell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please point me in the right direction.


-------> The API for JRootPane
 
Sean O'Donnell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I need to replace the LayoutManager, thanks!
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic