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

Menu Items are not appearing.

 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends , i got a small problem, below is the code. Thanks in advance.
My OS is windows 7.
frame.png
[Thumbnail for frame.png]
The File Menu is Clicked above & it is not showing its Menu items.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a component can have only one parent,
so, add 'exit'/'sbar' to the menu or the toolbar, not both
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your speedy response. i undestood.

but what if i want a common choice like "SAVE" on File Menu & Tool bar simultaneously..do i need to write extra object(toolbar item that represents same menu item). & do i need to write redundently the Listeners..?

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just add another button to the toolbar (also with e.g. "Exit"),
then set the button's model to that of the exitmenu's model
 
Rob Camick
Ranch Hand
Posts: 2612
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moguluri Ravi Kiran wrote:but what if i want a common choice like "SAVE" on File Menu & Tool bar simultaneously..do i need to write extra object(toolbar item that represents same menu item). & do i need to write redundently the Listeners..?


You need to create an Action that can be used by both components:



Read the section from the Swing tutorial on How to Use Actions for more information and examples.
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic