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


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
True or False.
Menus can be added to containers.
my ans: true
but the ans from Jxam is false, beacuse:Menus can only be added to menu-bars.
for my understanding, any class can hold a menu as long as it implements MenuContainer Interface. Since Component implements MenuContainer, so menu can be added to containers.
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi Tony,
The answer is false. the reason is that
if u see the spec of Container class then all forms of the add() method of container class takes Component as a parameter.
but Menu is not a Component rather it is a MenuComponent. & u can't add a MenuComponent to a Container.
hope this helps

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi Tony,
I think the answer is false, since only components can be added to a container. Menu is not a subclass of a Component but by MenuComponent, there is no way you can add a menu to a container. But what you can do is add the menu to a menu bar then you can add this menu bar to a frame using setMenuBar() method of the frame. Hope this might help.

Joined: Aug 18, 2000
Posts: 21
I think the question is a little bit ambiguous. The Container has a method inherited from Component add(PopupMenu). In terms of ineritance the PopupMenu is a Menu.
I agree. Here's the link:
subject: Menu?
jQuery in Action, 3rd edition