Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Menu (MenuBar, PopupMenu)

 
Sam Zheng
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have been baffled by the following questions for a while:
1. What containers can have Menu? In several different
occasions, I have seen different answers. In RHE's book,
it is said that only Frame can have Menu. However, in
another occasion (forgot the name of the book I read),
it is said that all these containers (Applet, Window,
Panel) can have Menu.
2. What determine whether a container can have Menu or not?
Thanks! Sam
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding is that only Frame can have menu components.
However, for PopupMenu, you can add it to almost all the containers.
Any correction on that?
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam, Adrian ...
I'm fairly certain Adrian is right. The Class Libraries state

The only valid parent for a MenuBar is a Frame instance.

And since Menu objects can only be inserted in MenuBar's; you can only build a Menu in a Frame.
On the other hand, a Pop-up Menu can be added to any component.
Hope that helps.

------------------
Jane
The cure for boredom is curiosity.
There is no cure for curiosity.
-- Dorothy Parker
 
Sam Zheng
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adrian and Jane, Thanks! One more question: If only Frame
can have Menu, then why all those containers (Panel, Applet,
Frame, etc) all implement MenuContainer interface? What
is this MenuContainer used for? Thanks again! Sam
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
Any component that can contain any MenuComponent has to implement MenuContainer Interface. and MenuComponent means....

Although only Frames can contain menubar but all components can contain popup menu. So Component class implements MenuContainer interface.
hope this clears your doubt.
regards
deekasha


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic