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
Joined: Oct 02, 2000
Posts: 688
posted
0
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
Joined: Aug 30, 2000
Posts: 3141
posted
0
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
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
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.