my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question about MenuBar and Frame? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a question about MenuBar and Frame?" Watch "a question about MenuBar and Frame?" New topic
Author

a question about MenuBar and Frame?

michael wang
Ranch Hand

Joined: Feb 06, 2002
Posts: 35
only Frames can contain menu bars or pull-down menus?
true or false
i think it true.
but the answer is false
so pls give me a explanation.
thanks


--<br />a java beginner from China
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
You forgot about subclassing!
All subclasses of Frame will also allow a menu bar and menus.
When reading these type of questions, look out for words like 'only' or 'all'
By the way, the question seems flawed? There is no such things as 'Frames' in java, but there is a class Frame, just my beef


<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Stephen Batsas
Ranch Hand

Joined: Jan 22, 2002
Posts: 117
Ranchers,
You can also attach a JMenuBar to a JApplet. I have done it. Check the API.
Regards,
Stephen Batsas
SCJP2
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Correct me if I am wrong, but the JMenuBar belongs to the Swing package which the SCJP2 Exam does not cover.
Other then what Stephen has said, under the AWT framework only Frame based classes can have a menubar?
[ March 04, 2002: Message edited by: Rajinder Yadav ]
Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213
This might seem silly, but possible if you wanted, you can also make a frame, then make a window and give ownership of the window to the frame you just created, and that window can support a menubar. So, without subclassing (which is perfectly viable), you can still have 2 classes that support a menubar.
Correct?
-Matt


-Matt<br /> SCJP2<br /> SCJD
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Giving ownership of a window to a frame still doesn't change the fact that you're dealing with a Frame... the frame object now owns the windows object
Originally posted by Matt Ghiold:
This might seem silly, but possible if you wanted, you can also make a frame, then make a window and give ownership of the window to the frame you just created, and that window can support a menubar. So, without subclassing (which is perfectly viable), you can still have 2 classes that support a menubar.
Correct?
-Matt
Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213

Giving ownership of a window to a frame still doesn't change the fact that you're dealing with a Frame... the frame object now owns the windows object

Yes, this is true, but the window would own the menubar =).
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
I guess you don't quite understand the concept of ownership, sorry to put it that way
Question, can you add a menu bar to a window object before making it a property of a frame? If the answer is no then windows can't have menu bars can they!
Owned in this context means the windows object is controlled by the frame, for all practical purpose they are one in the same!
Or maybe it's just me?
Just in case you are wondering, here it is straight out of the JDK, "A Window object is a top-level window with no borders and no menubar."
Originally posted by Matt Ghiold:

Yes, this is true, but the window would own the menubar =).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question about MenuBar and Frame?
 
Similar Threads
plz need help
You can directly run the GC whenever you want to ?????
Short Circuit AND
Double doubt
only static methods can access static members