本文整理汇总了Java中javax.swing.text.JTextComponent.KeyBinding方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.KeyBinding方法的具体用法?Java JTextComponent.KeyBinding怎么用?Java JTextComponent.KeyBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.JTextComponent
的用法示例。
在下文中一共展示了JTextComponent.KeyBinding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeymap
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public MultiKeymap getKeymap() {
synchronized (KEYMAPS_AND_ACTIONS_LOCK) {
MimePath mimePath = MimePath.parse(getContentType());
MultiKeymap km = (MultiKeymap)kitKeymaps.get(mimePath);
if (km == null) { // keymap not yet constructed
// construct new keymap
km = new MultiKeymap("Keymap for " + mimePath.getPath()); // NOI18N
// retrieve key bindings for this kit and super kits
KeyBindingSettings kbs = MimeLookup.getLookup(mimePath).lookup(KeyBindingSettings.class);
List<org.netbeans.api.editor.settings.MultiKeyBinding> mkbList = kbs.getKeyBindings();
List<JTextComponent.KeyBinding> editorMkbList = new ArrayList<JTextComponent.KeyBinding>();
for(org.netbeans.api.editor.settings.MultiKeyBinding mkb : mkbList) {
List<KeyStroke> keyStrokes = mkb.getKeyStrokeList();
MultiKeyBinding editorMkb = new MultiKeyBinding(keyStrokes.toArray(new KeyStroke[keyStrokes.size()]), mkb.getActionName());
editorMkbList.add(editorMkb);
}
// go through all levels and collect key bindings
km.load(editorMkbList.toArray(new JTextComponent.KeyBinding[editorMkbList.size()]), getActionMap());
km.setDefaultAction(getActionMap().get(defaultKeyTypedAction));
kitKeymaps.put(mimePath, km);
}
return km;
}
}
示例2: load
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Loads the key to action mappings into this keymap in similar way
* as JTextComponent.loadKeymap() does. This method is able to handle
* MultiKeyBindings but for compatibility it expects
* JTextComponent.KeyBinding array.
*/
public void load(JTextComponent.KeyBinding[] bindings, Action[] actions) {
Map h = new HashMap(bindings.length);
// add actions to map to resolve by names quickly
for (int i = 0; i < actions.length; i++) {
Action a = actions[i];
String value = (String)a.getValue(Action.NAME);
h.put((value != null ? value : ""), a); // NOI18N
}
load(bindings, h);
}
示例3: checkArray
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
if (keyActionArray.length != 1) {
throw new RuntimeException("Wrong array lenght!");
}
if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
throw new RuntimeException("Wrong action name!");
}
if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
throw new RuntimeException("Wrong keystroke!");
}
}
示例4: MultiKeyBinding
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Constructor for existing KeyBinding */
public MultiKeyBinding(JTextComponent.KeyBinding kb) {
this(kb.key, kb.actionName);
}