Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AWT question from javaprepare:

 
geetha nagarajan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of these classes can be added to a Frame component. Select all correct answers.
1.Menu
2.Button
3.PopupMenu
4.Window
5.List
Acc.to javaprepare,the answer is 2,3,5.
But,i think it's 1,2,3,5.All except Window,in this list can be added to a Frame.Pl.clarify.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API Spec. You can add anything that extends Component to a Frame. Menu, however, extends MenuComponent, so it can't be added.
Corey
[ May 29, 2002: Message edited by: Corey McGlone ]
 
Swati Gupta
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thing that we can use MenuBar with Frame using setMenuBar and we should add menu to menubar.
Please correct if I am wrong.
 
geetha nagarajan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Acc.to mughal(chp 12):
A frame is an optionally user resizable and movable top level window ,that can have a title-bar,an icon and menus.
Pl.clarify.
 
geetha nagarajan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya,i think we can add menubars to Frame ,using methods like setMenuBar().
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I accidentally pulled that from the Window API Spec, rather than the Frame API Spec. However, you still can't "add" a menu to a Frame. The add methods take Components, not MenuComponents. Rather you use the setMenuBar method to place a menu into the Frame.
The original question asks, speicifically, which ones can be "added" to the frame. A menu can not be.
I hope that helps,
Corey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic