KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > KeyStroke


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: KeyStroke.java,v $
11    Revision 1.5 2004/04/20 15:11:26 bobintetley
12    awt.MenuShortcut implementation
13
14    Revision 1.4 2004/04/16 10:19:07 dannaab
15    Misc bug fixes, InputMap implementation, preliminary undo support
16
17    Revision 1.3 2003/12/14 09:13:38 bobintetley
18    Added CVS log to source headers
19
20 */

21
22 package swingwtx.swing;
23
24
25 public class KeyStroke {
26     
27     private int keyCode = 0;
28     private int modifiers = 0;
29     
30     /** Only way to get one of these is through static methods */
31     private KeyStroke() { }
32
33     public static KeyStroke getKeyStroke(int keyCode, int modifiers) {
34         KeyStroke k = new KeyStroke();
35         k.setKeyCode(keyCode);
36         k.setModifiers(modifiers);
37         return k;
38     }
39     
40     /** FIXME: NEEDS IMPLEMENTING */
41     public static KeyStroke getKeyStroke(String JavaDoc namedConstant) {
42         // Translate named constant to key code and modifier
43
// Eg: "control a" for CTRL modifier _+ a
44
// "shift alt b" for SHIFT|ALT + b
45
return new KeyStroke();
46     }
47
48     public static KeyStroke getKeyStroke(int keyCode) {
49         return getKeyStroke(keyCode, 0);
50     }
51     
52     /** Getter for property keyCode.
53      * @return Value of property keyCode.
54      *
55      */

56     public int getKeyCode() {
57         return keyCode;
58     }
59     
60     /** Setter for property keyCode.
61      * @param keyCode New value of property keyCode.
62      *
63      */

64     public void setKeyCode(int keyCode) {
65         this.keyCode = keyCode;
66     }
67     
68     /** Getter for property modifiers.
69      * @return Value of property modifiers.
70      *
71      */

72     public int getModifiers() {
73         return modifiers;
74     }
75     
76     /** Setter for property modifiers.
77      * @param modifiers New value of property modifiers.
78      *
79      */

80     public void setModifiers(int modifiers) {
81         this.modifiers = modifiers;
82     }
83     
84 }
85
Popular Tags