File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes JMenuBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JMenuBar" Watch "JMenuBar" New topic


Jay Kamdar

Joined: Sep 02, 2005
Posts: 22
Should you use the JFrame's setJmenuBar method to a menu or the JFrame's getContentPane method and use the Container got that returned method add to menu if you are trying to get the menu to the top of the screen like normal toobars and menus?

How would you do the second one, I don't know how to position the menu in a Container?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

To use a JMenuBar, you use the setJMenuBar method of JFrame -- period. There's no standard provision for putting the menubar anywhere else. It goes at the top of the JFrame.

"Normal" is relative of course. Because you're mentioned the top of the screen, I wonder if you're talking about how things work on the Macintosh? If so, there is a platform-specific extension for doing that. If you are talking about Macs, let me know, and I'll move this to our MacOS forum; otherwise, I'll move it to our Swing forum.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: JMenuBar
jQuery in Action, 3rd edition