• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about Menu (MenuBar, PopupMenu)

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


reply
    Bookmark Topic Watch Topic
  • New Topic