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

Menu question

Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142
Heres my code:

As it is now. I am able to create a menu bar with a heading "file". When the user clicks on "file" the menu pops up and they can actually select one of four choices; I only have one of them listed here,"review".
How do I add a submenu to review? I want to add two options("Test" and "Tutorial") that pop up when the user's mouse lands on the word "Review..". The API said that I should use" ..... submenu is an instance of Menu." .
I need some code to help me out. I played around with add() with no success.
Thanks in advance.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You would do what you did to add the menu choice "Review". The only differences will be that you don't add it to m3, and that it must be added to an instance of Menu, not MenuItem. For example:
Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142

this now produces:
-Option 1
-Option 2
-Option 3
(The indentation didn;t work, but I got what I wanted!!!)
It seems so obvious now. I guess I was looking at it too long. Thanks for the help. This is
how I feel now.
I agree. Here's the link:
subject: Menu question
It's not a secret anymore!