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


Java Keymap类代码示例

本文整理汇总了Java中javax.swing.text.Keymap的典型用法代码示例。如果您正苦于以下问题:Java Keymap类的具体用法?Java Keymap怎么用?Java Keymap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Keymap类属于javax.swing.text包,在下文中一共展示了Keymap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ScrollCompletionPane.java

示例2: addAcceleretors

import javax.swing.text.Keymap; //导入依赖的package包/类
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
    // Try to get the accelerator
    Keymap km = target.getKeymap();

    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);

        if ((keys != null) && (keys.length > 0)) {
            item.setAccelerator(keys[0]);
        } else if (a != null) {
            KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);

            if (ks != null) {
                item.setAccelerator(ks);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CslEditorKit.java

示例3: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null && editorActionName != null) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CompletionScrollPane.java

示例4: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentationScrollPane.java

示例5: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentationScrollPane.java

示例6: applyShortcuts

import javax.swing.text.Keymap; //导入依赖的package包/类
private void applyShortcuts() {
if (!termOptions.getIgnoreKeymap()) {
    Set<String> actions = new HashSet<String>();
    for (FileObject def : shortcutsDir.getChildren()) {
	try {
	    DataObject dobj = DataObject.find(def);
	    InstanceCookie ic = dobj.getLookup().lookup(InstanceCookie.class);
	    if (ic != null) {
		// put class names in the map,
		// otherwise we may end with several instances of the action
		actions.add(ic.instanceCreate().getClass().getName());
	    }
	} catch (Exception e) {
	    Exceptions.printStackTrace(e);
	}
    }
    term.setKeymap(Lookup.getDefault().lookup(Keymap.class), actions);
    // needed for Ctrl+Tab, Ctrl+Shift+Tab switching
    term.getScreen().setFocusTraversalKeysEnabled(false);
} else {
    term.setKeymap(null, null);
    term.getScreen().setFocusTraversalKeysEnabled(true);
}
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Terminal.java

示例7: assignAccelerator

import javax.swing.text.Keymap; //导入依赖的package包/类
private static void assignAccelerator(Keymap km, Action action, JMenuItem item) {
    if (item.getAccelerator() == null){
        KeyStroke ks = (KeyStroke)action.getValue(Action.ACCELERATOR_KEY);
        if (ks!=null) {
            item.setMnemonic(ks.getKeyCode());
        } else {
            // Try to get the accelerator from keymap
            if (km != null) {
                KeyStroke[] keys = km.getKeyStrokesForAction(action);
                if (keys != null && keys.length > 0) {
                    item.setMnemonic(keys[0].getKeyCode());
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbEditorKit.java

示例8: addAcceleretors

import javax.swing.text.Keymap; //导入依赖的package包/类
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target){
    // Try to get the accelerator
    Keymap km = (target == null) ? BaseKit.getKit(BaseKit.class).getKeymap() :
            target.getKeymap();
    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);
        if (keys != null && keys.length > 0) {
            boolean added = false;
            for (int i = 0; i<keys.length; i++){
                if ((keys[i].getKeyCode() == KeyEvent.VK_MULTIPLY) ||
                    keys[i].getKeyCode() == KeyEvent.VK_ADD){
                    item.setMnemonic(keys[i].getKeyCode());
                    added = true;
                    break;
                }
            }
            if (added == false) item.setMnemonic(keys[0].getKeyCode());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:NbEditorKit.java

示例9: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(JTextComponent component, String editorActionName, KeyStroke defaultKey) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ScrollCompletionPane.java

示例10: addAccelerators

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Adds accelerators to given JMenuItem taken from the action */
protected static void addAccelerators(Action a, JMenuItem item, JTextComponent target){
    if (target == null || a==null || item==null) return;
    
    // get accelerators from kitAction
    Action kitAction = getActionByName((String)a.getValue(Action.NAME));
    if (kitAction!=null) a = kitAction;
    // Try to get the accelerator, TopComponent action could be obsoleted
    Keymap km = target.getKeymap();

    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);
        KeyStroke itemAccelerator = item.getAccelerator();
        
        if (keys != null && keys.length > 0) {
            if (itemAccelerator==null || !itemAccelerator.equals(keys[0])){
                item.setAccelerator(keys[0]);
            }
        }else{
            if (itemAccelerator!=null && kitAction!=null){
                item.setAccelerator(null);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:MainMenuAction.java

示例11: createKeymap

import javax.swing.text.Keymap; //导入依赖的package包/类
/**
 * Creates the {@link Keymap} that is installed on the text component.
 *
 * @return the {@link Keymap} that is installed on the text component
 */
protected Keymap createKeymap()
{
  String keymapName = getKeymapName();
  Keymap keymap = JTextComponent.getKeymap(keymapName);
  if (keymap == null)
    {
      Keymap parentMap =
        JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
      keymap = JTextComponent.addKeymap(keymapName, parentMap);
      Object val = UIManager.get(getPropertyPrefix() + ".keyBindings");
      if (val != null && val instanceof JTextComponent.KeyBinding[])
        {
          JTextComponent.KeyBinding[] bindings =
            (JTextComponent.KeyBinding[]) val;
          JTextComponent.loadKeymap(keymap, bindings,
                                    getComponent().getActions());
        }
    }
  return keymap;
}
 
开发者ID:vilie,项目名称:javify,代码行数:26,代码来源:BasicTextUI.java

示例12: addAcceleretors

import javax.swing.text.Keymap; //导入依赖的package包/类
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target){
    // Try to get the accelerator
    Keymap km = target.getKeymap();
    if (km != null) {

        KeyStroke[] keys = km.getKeyStrokesForAction(a);
        if (keys != null && keys.length > 0) {
            item.setAccelerator(keys[0]);
        }else if (a!=null){
            KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
            if (ks!=null) {
                item.setAccelerator(ks);
            }
        }
    }
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:17,代码来源:GrammarEditorKit.java

示例13: findEditorKeys

import javax.swing.text.Keymap; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:18,代码来源:CompletionScrollPane.java

示例14: createBackup

import javax.swing.text.Keymap; //导入依赖的package包/类
private static void createBackup() {
    Keymap oldBackup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[0].getClass().getName());
    if (oldBackup != null) {
        // if there is already a backup, do not create a new backup
        return;
    }

    for (JTextComponent jtc : EmacsKeyBindings.JTCS) {
        Keymap orig = jtc.getKeymap();
        Keymap backup = JTextComponent.addKeymap
                (jtc.getClass().getName(), null);
        Action[] bound = orig.getBoundActions();
        for (Action aBound : bound) {
            KeyStroke[] strokes = orig.getKeyStrokesForAction(aBound);
            for (KeyStroke stroke : strokes) {
                backup.addActionForKeyStroke(stroke, aBound);
            }
        }
        backup.setDefaultAction(orig.getDefaultAction());
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:22,代码来源:EmacsKeyBindings.java

示例15: unload

import javax.swing.text.Keymap; //导入依赖的package包/类
/**
 * Restores the original keybindings for the concrete subclasses of
 * {@link JTextComponent}.
 */
public static void unload() {
    for (int i = 0; i < EmacsKeyBindings.JTCS.length; i++) {
        Keymap backup = JTextComponent.getKeymap
                (EmacsKeyBindings.JTCS[i].getClass().getName());

        if (backup != null) {
            Keymap current = EmacsKeyBindings.JTCS[i].getKeymap();
            current.removeBindings();

            Action[] bound = backup.getBoundActions();
            for (Action aBound : bound) {
                KeyStroke[] strokes =
                        backup.getKeyStrokesForAction(bound[i]);
                for (KeyStroke stroke : strokes) {
                    current.addActionForKeyStroke(stroke, aBound);
                }
            }
            current.setDefaultAction(backup.getDefaultAction());
        }
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:26,代码来源:EmacsKeyBindings.java


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