KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > MenuItem


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: MenuItem.java,v $
11    Revision 1.5 2004/04/20 15:11:25 bobintetley
12    awt.MenuShortcut implementation
13
14    Revision 1.4 2004/01/15 10:11:14 bobintetley
15    Fixed AWT constructors/hierarchy
16
17    Revision 1.3 2003/12/14 09:13:38 bobintetley
18    Added CVS log to source headers
19
20 */

21
22 package swingwt.awt;
23
24 import swingwtx.swing.KeyStroke;
25
26 public class MenuItem extends swingwtx.swing.JMenuItem {
27     
28     protected MenuShortcut shortcut = null;
29     
30     public MenuItem() { super(); }
31     public MenuItem(String JavaDoc text) { super(text); }
32     
33     public void setShortcut(MenuShortcut s) {
34         // Translate menu shortcut to swing Keystroke
35
shortcut = s;
36         KeyStroke ks = KeyStroke.getKeyStroke( s.getKey(),
37             ( s.usesShiftModifier() ? swingwt.awt.event.KeyEvent.SHIFT_MASK : 0 ) |
38             swingwt.awt.event.KeyEvent.CTRL_MASK
39             );
40         super.setAccelerator(ks);
41     }
42     
43     public MenuShortcut getShortcut() { return shortcut; }
44 }
45
Popular Tags