45 |
import java.net.URL; |
import java.net.URL; |
46 |
|
|
47 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
48 |
|
import javax.swing.plaf.ComponentInputMapUIResource; |
49 |
import javax.swing.plaf.IconUIResource; |
import javax.swing.plaf.IconUIResource; |
50 |
|
import javax.swing.plaf.InputMapUIResource; |
51 |
import javax.swing.plaf.UIResource; |
import javax.swing.plaf.UIResource; |
52 |
import javax.swing.text.JTextComponent; |
import javax.swing.text.JTextComponent; |
53 |
|
|
185 |
public abstract boolean isSupportedLookAndFeel(); |
public abstract boolean isSupportedLookAndFeel(); |
186 |
|
|
187 |
/** |
/** |
188 |
* Loads the bindings in keys into retMap. |
* Loads the bindings in keys into retMap. Does not remove existing entries |
189 |
|
* from retMap. <code>keys</code> describes the InputMap, every even indexed |
190 |
|
* item is either a KeyStroke or a String representing a KeyStroke and every |
191 |
|
* odd indexed item is the Object associated with that KeyStroke in an |
192 |
|
* ActionMap. |
193 |
|
* |
194 |
|
* @param retMap the InputMap into which we load bindings |
195 |
|
* @param keys the Object array describing the InputMap as above |
196 |
*/ |
*/ |
197 |
public static void loadKeyBindings(InputMap retMap, Object[] keys) |
public static void loadKeyBindings(InputMap retMap, Object[] keys) |
198 |
{ |
{ |
199 |
// TODO: Implement this properly. |
if (keys == null) |
200 |
|
return; |
201 |
|
for (int i = 0; i < keys.length - 1; i+= 2) |
202 |
|
{ |
203 |
|
Object key = keys[i]; |
204 |
|
KeyStroke keyStroke; |
205 |
|
if (key instanceof KeyStroke) |
206 |
|
keyStroke = (KeyStroke)key; |
207 |
|
else |
208 |
|
keyStroke = KeyStroke.getKeyStroke((String)key); |
209 |
|
retMap.put(keyStroke, keys[i+1]); |
210 |
|
} |
211 |
} |
} |
212 |
|
|
213 |
/** |
/** |
214 |
* Creates a ComponentInputMap from keys. |
* Creates a ComponentInputMap from keys. |
215 |
|
* <code>keys</code> describes the InputMap, every even indexed |
216 |
|
* item is either a KeyStroke or a String representing a KeyStroke and every |
217 |
|
* odd indexed item is the Object associated with that KeyStroke in an |
218 |
|
* ActionMap. |
219 |
|
* |
220 |
|
* @param c the JComponent associated with the ComponentInputMap |
221 |
|
* @param keys the Object array describing the InputMap as above |
222 |
*/ |
*/ |
223 |
public static ComponentInputMap makeComponentInputMap(JComponent c, |
public static ComponentInputMap makeComponentInputMap(JComponent c, |
224 |
Object[] keys) |
Object[] keys) |
225 |
{ |
{ |
226 |
return null; |
ComponentInputMap retMap = new ComponentInputMapUIResource(c); |
227 |
|
loadKeyBindings(retMap, keys); |
228 |
|
return retMap; |
229 |
} |
} |
230 |
|
|
231 |
/** |
/** |
246 |
|
|
247 |
/** |
/** |
248 |
* Creates a InputMap from keys. |
* Creates a InputMap from keys. |
249 |
|
* <code>keys</code> describes the InputMap, every even indexed |
250 |
|
* item is either a KeyStroke or a String representing a KeyStroke and every |
251 |
|
* odd indexed item is the Object associated with that KeyStroke in an |
252 |
|
* ActionMap. |
253 |
|
* |
254 |
|
* @param keys the Object array describing the InputMap as above |
255 |
*/ |
*/ |
256 |
public static InputMap makeInputMap(Object[] keys) |
public static InputMap makeInputMap(Object[] keys) |
257 |
{ |
{ |
258 |
return null; |
InputMap retMap = new InputMapUIResource(); |
259 |
|
loadKeyBindings(retMap, keys); |
260 |
|
return retMap; |
261 |
} |
} |
262 |
|
|
263 |
/** |
/** |
264 |
* Convenience method for building lists of KeyBindings. |
* Convenience method for building lists of KeyBindings. |
265 |
|
* <code>keyBindingList</code> is an array of KeyStroke-Action pairs where |
266 |
|
* even indexed elements are KeyStrokes or Strings representing KeyStrokes |
267 |
|
* and odd indexed elements are the associated Actions. |
268 |
|
* |
269 |
|
* @param keyBindingList the array of KeyStroke-Action pairs |
270 |
|
* @return a JTextComponent.KeyBinding array |
271 |
*/ |
*/ |
272 |
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList) |
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList) |
273 |
{ |
{ |
274 |
return null; |
JTextComponent.KeyBinding[] retBindings = |
275 |
|
new JTextComponent.KeyBinding[keyBindingList.length / 2]; |
276 |
|
for (int i = 0; i < keyBindingList.length - 1; i+= 2) |
277 |
|
{ |
278 |
|
KeyStroke stroke; |
279 |
|
if (keyBindingList[i] instanceof KeyStroke) |
280 |
|
stroke = (KeyStroke)keyBindingList[i]; |
281 |
|
else |
282 |
|
stroke = KeyStroke.getKeyStroke((String)keyBindingList[i]); |
283 |
|
retBindings[i/2] = new JTextComponent.KeyBinding(stroke, (String)keyBindingList[i+1]); |
284 |
|
} |
285 |
|
return retBindings; |
286 |
} |
} |
287 |
|
|
288 |
/** |
/** |