Sun Java Solaris Communities My SDN Account Join SDN
 
Code sample

Code Samples from the Java Developers Almanac 2000

 
javax.accessibility
Code Samples Index

These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms

Setting a Keyboard Accelerator for a Menu Item

At least one menu in a menu bar should have a mnemonic. This makes all the menus and menu items accessible.

    
 JMenuItem item = new JMenuItem("Item");
 
 //The next two lines should be in one line.
 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.
   VK_I, KeyEvent.SHIFT_MASK));
 
 

Examplets provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Order this book from Amazon