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
Joined: Jun 09, 2003
Posts: 4632
posted
0
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
Joined: Jun 13, 2009
Posts: 1787
2
posted
1
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.