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.
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
Joined: Nov 22, 2008
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!