This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
mohit chilkoti wrote:
I don't want to make corresponding menu-items for every toolbar button to achieve this.
Why? What problem are you trying to avoid by taking this approach?
In theory, I suppose you can achieve it by using key bindings. But that is a horrible design in my opinion.
The accelerators are for the buttons/menus. It makes sense to have the accelerator code with those items.
Usually the toolbar displays visual representation of items, which are already present with in the menu bar.
Then it makes even more sense to have similar items share the same subclassed AbstractAction