Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Menu?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic