• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Menu Bar

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a question about Menu Bar
According to RHE
Which of the following may contain a menu bar? (Choose all that apply.)
A) A panel
B) A frame
C) An applet
D) A menu bar
E) A menu
The Answer is B, a frame only but I got impression that all of them "panel, applet, window and frame" can contain a menu bar. I forgot where I got this information. Any input sure be appreciated.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It is true that MenuBar can be added
only to frames. The menubar is added using
the setMenuBar(aMenuBarObjRef) method.
This method is currently supported only be
frames. Check out this example:

Play with the code and you will getit.
Hope this helps.
Regds.
- satya
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Java 2 Exam Cram" by Bill Brogden says:
Chapter 11, Question 2
"Which of the following AWT components can have a menu, either as a menu bar or pop-up menu, attached to it?
a) Frame
b) Window
c) Applet
d) Panel
Answers a, b, c, and d are correct. All of these components may have an attached menu because the Component class implements the MenuContainer interface, and all of these classes have Component in their ancestry."
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Madhav is right. I checked the Java doc, only Frame has the method setMenuBar() which attachs the menubar to a container. Correct me if I'm wrong. Thanks,
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, yanish:

If you read Bill's question carefully, you will find it says "either as a menu bar or pop-up menu, attached to it". The word
"or" make answers a, b, c, d all correct. From API, there is a add(PopupMenu popup) function in Component class. Since Frame, Window, Applet, Panel are grandchildern of Components, all the answers will be right.
Kevin Fu
 
This tiny ad is suggesting that maybe she should go play in traffic.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic