This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

Menu?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Question:
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
regards
deekasha


Anonymous
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.
cheers!
yanish
Greenhorn

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.
 
GeeCON Prague 2014
 
subject: Menu?