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


Java InputMap.allKeys方法代码示例

本文整理汇总了Java中javax.swing.InputMap.allKeys方法的典型用法代码示例。如果您正苦于以下问题:Java InputMap.allKeys方法的具体用法?Java InputMap.allKeys怎么用?Java InputMap.allKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.InputMap的用法示例。


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

示例1: exchangeCommands

import javax.swing.InputMap; //导入方法依赖的package包/类
private static void exchangeCommands(String[][] commandsToExchange,
        final JComponent target, final JComponent source) {
    InputMap targetBindings = target.getInputMap();
    KeyStroke[] targetBindingKeys = targetBindings.allKeys();
    ActionMap targetActions = target.getActionMap();
    InputMap sourceBindings = source.getInputMap();
    ActionMap sourceActions = source.getActionMap();
    for (int i = 0; i < commandsToExchange.length; i++) {
        String commandFrom = commandsToExchange[i][0];
        String commandTo = commandsToExchange[i][1];
        final Action orig = targetActions.get(commandTo);
        if (orig == null) {
            continue;
        }
        sourceActions.put(commandTo, new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                orig.actionPerformed(new ActionEvent(target, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()));
            }
        });
        for (int j = 0; j < targetBindingKeys.length; j++) {
            if (targetBindings.get(targetBindingKeys[j]).equals(commandFrom)) {
                sourceBindings.put(targetBindingKeys[j], commandTo);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AddModulePanel.java

示例2: getKeyStrokeFor

import javax.swing.InputMap; //导入方法依赖的package包/类
private String getKeyStrokeFor(String action) {
    JSONArray r = new JSONArray();
    if (component instanceof JComponent) {
        InputMap inputMap = ((JComponent) component).getInputMap();
        KeyStroke[] allKeys = inputMap.allKeys();
        for (KeyStroke ks : allKeys) {
            if (action.equals(inputMap.get(ks))) {
                r.put(ks.toString());
            }
        }
    }
    if (r.length() > 0) {
        return r.toString();
    }
    return null;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:JavaElementPropertyAccessor.java

示例3: getOSKey

import javax.swing.InputMap; //导入方法依赖的package包/类
private JavaAgentKeys getOSKey() {
    KeyStroke selectall = null;
    InputMap inputMap = new JTextField().getInputMap();
    KeyStroke[] allKeys = inputMap.allKeys();
    for (KeyStroke keyStroke : allKeys) {
        Object object = inputMap.get(keyStroke);
        if (object.equals("select-all")) {
            selectall = keyStroke;
            break;
        }
    }
    if ((selectall.getModifiers() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
        return JavaAgentKeys.CONTROL;
    }
    if ((selectall.getModifiers() & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK) {
        return JavaAgentKeys.META;
    }
    throw new RuntimeException("Which key?");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:DeviceKBTest.java

示例4: checkKeystrokesForActions

import javax.swing.InputMap; //导入方法依赖的package包/类
public void checkKeystrokesForActions() throws Throwable {
    StringBuilder sb = new StringBuilder();
    driver = new JavaDriver();
    WebElement textField = driver.findElement(By.cssSelector("text-field"));
    JTextField f = new JTextField();
    InputMap inputMap = f.getInputMap();
    KeyStroke[] allKeys = inputMap.allKeys();
    for (KeyStroke keyStroke : allKeys) {
        Object object = inputMap.get(keyStroke);
        try {
            OSUtils.getKeysFor(textField, object.toString());
        } catch (Throwable t) {
            sb.append("failed for(" + object + "): " + keyStroke);
        }
    }
    AssertJUnit.assertEquals("", sb.toString());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:JTextFieldTest.java

示例5: toString

import javax.swing.InputMap; //导入方法依赖的package包/类
/** Converts an action map to a string representation. */
static public String toString(InputMap im) {
    StringBuilder result = new StringBuilder();
    LinkedHashMap<Object,Object> map = new LinkedHashMap<>();
    for (KeyStroke key : im.allKeys()) {
        map.put(key, im.get(key));
    }
    result.append(map);
    result.append('\n');
    InputMap parent = im.getParent();
    if (parent != null) {
        result.append("Parent: ");
        result.append(toString(parent));
    }
    return result.toString();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:Groove.java


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