当前位置: 首页>>代码示例>>Java>>正文


Java JTextComponent.KeyBinding方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:BaseKit.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:MultiKeymap.java

示例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!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:bug6474153.java

示例4: MultiKeyBinding

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Constructor for existing KeyBinding */
public MultiKeyBinding(JTextComponent.KeyBinding kb) {
    this(kb.key, kb.actionName);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:MultiKeyBinding.java


注:本文中的javax.swing.text.JTextComponent.KeyBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。