The MenuItem class also provides a feature of menu shortcuts and speed keys. You must be familiar with the menu shortcuts such as Ctrl-P which is used to give a print command rather than going to the File menu. A shortcut to any of the MenuItem can be created with the help of MenuItem class. The use of Ctrl for the shortcut key is defined by the Toolkit method which is getMenuShortcutKeyMask().
Lets see how to create menu items with speed keys i.e. Ctrl-P for Print and Shift-Ctrl-P for Print Preview:
file.add (m = new MenuItem ("Print", new
file.add (m = new MenuItem ("Print Preview", new MenuShortcut('p', true)));
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: December 18, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles