KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > text > Keymap


1 /*
2  * @(#)Keymap.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.text;
8
9 import javax.swing.Action JavaDoc;
10 import javax.swing.KeyStroke JavaDoc;
11
12 /**
13  * A collection of bindings of KeyStrokes to actions. The
14  * bindings are basically name-value pairs that potentially
15  * resolve in a hierarchy.
16  *
17  * @author Timothy Prinzing
18  * @version 1.18 12/19/03
19  */

20 public interface Keymap {
21
22     /**
23      * Fetches the name of the set of key-bindings.
24      *
25      * @return the name
26      */

27     public String JavaDoc getName();
28
29     /**
30      * Fetches the default action to fire if a
31      * key is typed (i.e. a KEY_TYPED KeyEvent is received)
32      * and there is no binding for it. Typically this
33      * would be some action that inserts text so that
34      * the keymap doesn't require an action for each
35      * possible key.
36      *
37      * @return the default action
38      */

39     public Action JavaDoc getDefaultAction();
40
41     /**
42      * Set the default action to fire if a key is typed.
43      *
44      * @param a the action
45      */

46     public void setDefaultAction(Action JavaDoc a);
47
48     /**
49      * Fetches the action appropriate for the given symbolic
50      * event sequence. This is used by JTextController to
51      * determine how to interpret key sequences. If the
52      * binding is not resolved locally, an attempt is made
53      * to resolve through the parent keymap, if one is set.
54      *
55      * @param key the key sequence
56      * @return the action associated with the key
57      * sequence if one is defined, otherwise <code>null</code>
58      */

59     public Action JavaDoc getAction(KeyStroke JavaDoc key);
60
61     /**
62      * Fetches all of the keystrokes in this map that
63      * are bound to some action.
64      *
65      * @return the list of keystrokes
66      */

67     public KeyStroke JavaDoc[] getBoundKeyStrokes();
68
69     /**
70      * Fetches all of the actions defined in this keymap.
71      *
72      * @return the list of actions
73      */

74     public Action JavaDoc[] getBoundActions();
75
76     /**
77      * Fetches the keystrokes that will result in
78      * the given action.
79      *
80      * @param a the action
81      * @return the list of keystrokes
82      */

83     public KeyStroke JavaDoc[] getKeyStrokesForAction(Action JavaDoc a);
84
85     /**
86      * Determines if the given key sequence is locally defined.
87      *
88      * @param key the key sequence
89      * @return true if the key sequence is locally defined else false
90      */

91     public boolean isLocallyDefined(KeyStroke JavaDoc key);
92
93     /**
94      * Adds a binding to the keymap.
95      *
96      * @param key the key sequence
97      * @param a the action
98      */

99     public void addActionForKeyStroke(KeyStroke JavaDoc key, Action JavaDoc a);
100
101     /**
102      * Removes a binding from the keymap.
103      *
104      * @param keys the key sequence
105      */

106     public void removeKeyStrokeBinding(KeyStroke JavaDoc keys);
107
108     /**
109      * Removes all bindings from the keymap.
110      */

111     public void removeBindings();
112
113     /**
114      * Fetches the parent keymap used to resolve key-bindings.
115      *
116      * @return the keymap
117      */

118     public Keymap JavaDoc getResolveParent();
119
120     /**
121      * Sets the parent keymap, which will be used to
122      * resolve key-bindings.
123      *
124      * @param parent the parent keymap
125      */

126     public void setResolveParent(Keymap JavaDoc parent);
127
128 }
129
Popular Tags