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


Java InputMap.get方法代码示例

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


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

示例1: 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

示例2: 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

示例3: consumeIfKeyPressInActionMap

import javax.swing.InputMap; //导入方法依赖的package包/类
private void consumeIfKeyPressInActionMap(KeyEvent e) {
    // get popup's registered keyboard actions
    ActionMap am = popup.getActionMap();
    InputMap  im = popup.getInputMap();

    // check whether popup registers keystroke
    // If we consumed key pressed, we need to consume other key events as well:
    KeyStroke ks = KeyStroke.getKeyStrokeForEvent(
            new KeyEvent((Component) e.getSource(),
                         KeyEvent.KEY_PRESSED,
                         e.getWhen(),
                         e.getModifiers(),
                         KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()),
                         e.getKeyChar(),
                         e.getKeyLocation())
    );
    Object obj = im.get(ks);
    if (obj != null && !obj.equals("tooltip-no-action") //NOI18N ignore ToolTipSupport installed actions
    ) {
        // if yes, if there is a popup's action, consume key event
        Action action = am.get(obj);
        if (action != null && action.isEnabled()) {
            // actionPerformed on key press only.
            e.consume();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:PopupManager.java

示例4: getCopyActionDelegate

import javax.swing.InputMap; //导入方法依赖的package包/类
private Action getCopyActionDelegate(InputMap map, KeyStroke ks) {
    ActionMap am = getActionMap();

    if(map != null && am != null && isEnabled()) {
        Object binding = map.get(ks);
        final Action action = (binding == null) ? null : am.get(binding);
        if (action != null) {
            return new CopyToClipboardAction(action);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:OutlineView.java

示例5: actionPerformed

import javax.swing.InputMap; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    if (isEditing() || editorComp != null) {
        removeEditor();
        return;
    } else {
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        
        InputMap imp = getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = getRootPane().getActionMap();
        
        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);
        if (key == null) {
            //Default for NbDialog
            key = "Cancel";
        }
        if (key != null) {
            Action a = am.get(key);
            if (a != null) {
                String commandKey = (String)a.getValue(Action.ACTION_COMMAND_KEY);
                if (commandKey == null) {
                    commandKey = key.toString();
                }
                a.actionPerformed(new ActionEvent(this,
                ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ETable.java

示例6: listActionFor

import javax.swing.InputMap; //导入方法依赖的package包/类
@CheckForNull
private Pair<String,JComponent> listActionFor(KeyEvent ev) {
    InputMap map = matchesList.getInputMap();
    Object o = map.get(KeyStroke.getKeyStrokeForEvent(ev));
    if (o instanceof String) {
        return Pair.<String,JComponent>of((String)o, matchesList);
    }
    map = matchesScrollPane1.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    o = map.get(KeyStroke.getKeyStrokeForEvent(ev));
    if (o instanceof String) {
        return Pair.<String,JComponent>of((String)o, matchesScrollPane1);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:GoToPanelImpl.java

示例7: listActionFor

import javax.swing.InputMap; //导入方法依赖的package包/类
@CheckForNull
private Pair<String,JComponent> listActionFor(KeyEvent ev) {
    InputMap map = resultList.getInputMap();
    Object o = map.get(KeyStroke.getKeyStrokeForEvent(ev));
    if (o instanceof String) {
        return Pair.<String,JComponent>of((String)o, resultList);
    }
    map = resultScrollPane.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    o = map.get(KeyStroke.getKeyStrokeForEvent(ev));
    if (o instanceof String) {
        return Pair.<String,JComponent>of((String)o, resultScrollPane);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FileSearchPanel.java

示例8: keyPressed

import javax.swing.InputMap; //导入方法依赖的package包/类
public @Override void keyPressed(KeyEvent e){
    if (e != null && popup != null && popup.isShowing()) {
        
        // get popup's registered keyboard actions
        ActionMap am = popup.getActionMap();
        InputMap  im = popup.getInputMap();
        
        // check whether popup registers keystroke
        KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
        Object obj = im.get(ks);
        LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N
        if (obj != null && !obj.equals("tooltip-no-action") //NOI18N ignore ToolTipSupport installed actions
        ) {
            // if yes, gets the popup's action for this keystroke, perform it 
            // and consume key event
            Action action = am.get(obj);
            LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N

            if (action != null && action.isEnabled()) {
                action.actionPerformed(null);
                e.consume();
                return;
            }
        }

        if (e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH &&
            e.getKeyCode() != KeyEvent.VK_META
        ) {
            // hide tooltip if any was shown
            Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:PopupManager.java

示例9: trySendEscToDialog

import javax.swing.InputMap; //导入方法依赖的package包/类
/** Transmits escape sequence to dialog */
private void trySendEscToDialog() {
    if (isTableUI()) {
        //let the table decide, don't be preemptive
        return;
    }

    //        System.err.println("SendEscToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ESCAPE)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        InputMap imp = getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = getRootPane().getActionMap();

        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);

        if (key != null) {
            Action a = am.get(key);

            if (a != null) {
                if (Boolean.getBoolean("netbeans.proppanel.logDialogActions")) { //NOI18N
                    System.err.println("Action bound to escape key is " + a); //NOI18N
                }

                String commandKey = (String) a.getValue(Action.ACTION_COMMAND_KEY);

                if (commandKey == null) {
                    commandKey = "cancel"; //NOI18N
                }

                a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:EditablePropertyDisplayer.java

示例10: trySendEscToDialog

import javax.swing.InputMap; //导入方法依赖的package包/类
private void trySendEscToDialog(JTable jt) {
    //        System.err.println("SendEscToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ESCAPE)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        InputMap imp = jt.getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = jt.getRootPane().getActionMap();

        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);

        if (key != null) {
            Action a = am.get(key);

            if (a != null) {
                if (Boolean.getBoolean("netbeans.proppanel.logDialogActions")) { //NOI18N
                    System.err.println("Action bound to escape key is " + a); //NOI18N
                }

                //Actions registered with deprecated registerKeyboardAction will
                //need this lookup of the action command
                String commandKey = (String) a.getValue(Action.ACTION_COMMAND_KEY);

                if (commandKey == null) {
                    commandKey = "cancel"; //NOI18N
                }

                a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:BaseTable.java

示例11: installKeyBindings

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Registers keyboard actions to listen for in the text component and
 * intercept.
 *
 * @see #uninstallKeyBindings()
 */
private void installKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("PopupWindow: Installing keybindings");
	}
	if (keyBindingsInstalled) {
		System.err.println("Error: key bindings were already installed");
		Thread.dumpStack();
		return;
	}

	if (escapeKap==null) { // Lazily create actions.
		createKeyActionPairs();
	}

	JTextComponent comp = ac.getTextComponent();
	InputMap im = comp.getInputMap();
	ActionMap am = comp.getActionMap();

	replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape);
	if (AutoCompletion.getDebug() && oldEscape.action==escapeKap.action) {
		Thread.dumpStack();
	}
	replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp);
	replaceAction(im, am, KeyEvent.VK_LEFT, leftKap, oldLeft);
	replaceAction(im, am, KeyEvent.VK_DOWN, downKap, oldDown);
	replaceAction(im, am, KeyEvent.VK_RIGHT, rightKap, oldRight);
	replaceAction(im, am, KeyEvent.VK_ENTER, enterKap, oldEnter);
	replaceAction(im, am, KeyEvent.VK_TAB, tabKap, oldTab);
	replaceAction(im, am, KeyEvent.VK_HOME, homeKap, oldHome);
	replaceAction(im, am, KeyEvent.VK_END, endKap, oldEnd);
	replaceAction(im, am, KeyEvent.VK_PAGE_UP, pageUpKap, oldPageUp);
	replaceAction(im, am, KeyEvent.VK_PAGE_DOWN, pageDownKap, oldPageDown);

	// Make Ctrl+C copy from description window.  This isn't done
	// automagically because the desc. window is not focusable, and copying
	// from text components can only be done from focused components.
	KeyStroke ks = getCopyKeyStroke();
	oldCtrlC.key = im.get(ks);
	im.put(ks, ctrlCKap.key);
	oldCtrlC.action = am.get(ctrlCKap.key);
	am.put(ctrlCKap.key, ctrlCKap.action);

	comp.addCaretListener(this);

	keyBindingsInstalled = true;

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:55,代码来源:AutoCompletePopupWindow.java

示例12: installKeyBindings

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Installs key bindings on the text component that facilitate the user
 * editing this completion's parameters.
 *
 * @see #uninstallKeyBindings()
 */
private void installKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("CompletionContext: Installing keybindings");
	}

	JTextComponent tc = ac.getTextComponent();
	InputMap im = tc.getInputMap();
	ActionMap am = tc.getActionMap();

	KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
	oldTabKey = im.get(ks);
	im.put(ks, IM_KEY_TAB);
	oldTabAction = am.get(IM_KEY_TAB);
	am.put(IM_KEY_TAB, new NextParamAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
	oldShiftTabKey = im.get(ks);
	im.put(ks, IM_KEY_SHIFT_TAB);
	oldShiftTabAction = am.get(IM_KEY_SHIFT_TAB);
	am.put(IM_KEY_SHIFT_TAB, new PrevParamAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
	oldUpKey = im.get(ks);
	im.put(ks, IM_KEY_UP);
	oldUpAction = am.get(IM_KEY_UP);
	am.put(IM_KEY_UP, new NextChoiceAction(-1, oldUpAction));

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
	oldDownKey = im.get(ks);
	im.put(ks, IM_KEY_DOWN);
	oldDownAction = am.get(IM_KEY_DOWN);
	am.put(IM_KEY_DOWN, new NextChoiceAction(1, oldDownAction));

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
	oldEnterKey = im.get(ks);
	im.put(ks, IM_KEY_ENTER);
	oldEnterAction = am.get(IM_KEY_ENTER);
	am.put(IM_KEY_ENTER, new GotoEndAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	oldEscapeKey = im.get(ks);
	im.put(ks, IM_KEY_ESCAPE);
	oldEscapeAction = am.get(IM_KEY_ESCAPE);
	am.put(IM_KEY_ESCAPE, new HideAction());

	char end = pc.getProvider().getParameterListEnd();
	ks = KeyStroke.getKeyStroke(end);
	oldClosingKey = im.get(ks);
	im.put(ks, IM_KEY_CLOSING);
	oldClosingAction = am.get(IM_KEY_CLOSING);
	am.put(IM_KEY_CLOSING, new ClosingAction());

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:61,代码来源:ParameterizedCompletionContext.java

示例13: replaceAction

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Replaces a key/Action pair in an InputMap and ActionMap with a new
 * pair.
 *
 * @param im The input map.
 * @param am The action map.
 * @param key The keystroke whose information to replace.
 * @param kap The new key/Action pair for <code>key</code>.
 * @param old A buffer in which to place the old key/Action pair.
 * @see #putBackAction(InputMap, ActionMap, int, KeyActionPair)
 */
private void replaceAction(InputMap im, ActionMap am, int key,
					KeyActionPair kap, KeyActionPair old) {
	KeyStroke ks = KeyStroke.getKeyStroke(key, 0);
	old.key = im.get(ks);
	im.put(ks, kap.key);
	old.action = am.get(kap.key);
	am.put(kap.key, kap.action);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:20,代码来源:AutoCompletePopupWindow.java


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