當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。