@Override public Object get(KeyStroke keyStroke) { return inputMap.get(keyStroke); }
public static void maybeInstall(InputMap map, String action, KeyStroke stroke) { if (map.get(stroke) == null) { map.put(stroke, action); } }
InputMap im = checkB.getInputMap(); KeyStroke existingKeyStroke = KeyStroke.getKeyStroke("SPACE"); KeyStroke addedKeyStroke = KeyStroke.getKeyStroke("ENTER"); im.put(addedKeyStroke, im.get(existingKeyStroke)); existingKeyStroke = KeyStroke.getKeyStroke("released SPACE"); addedKeyStroke = KeyStroke.getKeyStroke("released ENTER"); im.put(addedKeyStroke, im.get(existingKeyStroke));
InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); KeyStroke f2 = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0); im.put(enter, im.get(f2));
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); im.put(enter, im.get(tab));
private void remap(InputMap inputs, int code) { Object key = inputs.get(KeyStroke.getKeyStroke(code, 0)); if (key != null) inputs.put(KeyStroke.getKeyStroke( code, InputEvent.ALT_DOWN_MASK), key); }
InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap am = table.getActionMap(); KeyStroke tabKey = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); Action moveNextCellAction = am.get(im.get(tabKey)); ContinousEditAction continousEditAction = new ContinousEditAction(table, moveNextCellAction); im.put(tabKey, "Action.tab"); am.put("Action.tab", continousEditAction);
private Object getKeyForActionMap(JComponent component, KeyStroke keyStroke) { for (int i = 0; i < 3; i++) { InputMap inputMap = component.getInputMap(i); if (inputMap != null) { Object key = inputMap.get(keyStroke); if (key != null) { return key; } } } return null; }
private boolean isNavigationKey(JTable table, KeyEvent event) { InputMap inputMap = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); return inputMap != null && inputMap.get(KeyStroke.getKeyStroke(event.getKeyCode(), 0)) != null; }
private KeyStroke removeEntry(InputMap inputMap, String keyToBeRemoved) { KeyStroke removedEntry = null; for (KeyStroke ks : inputMap.keys()) { String key = (String) inputMap.get(ks); if (key.equals(keyToBeRemoved)) { inputMap.remove(ks); removedEntry = ks; break; } } return removedEntry; }
public final void addDefaultKeyStroke(Object actionMapKey, KeyStroke keyStroke, Action action) { defaultActionMap.put(actionMapKey, action); defaultInputMap.put(keyStroke, actionMapKey); @SuppressWarnings("unchecked") List<DockingDesktop> desktopList = dockingContext.getDesktopList(); if (desktopList != null) { for (DockingDesktop d : desktopList) { d.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, defaultInputMap.get(keyStroke)); d.getActionMap().put(actionMapKey, defaultActionMap.get(actionMapKey)); } } }
private String listActionFor(KeyEvent ev) { InputMap map = resultList.getInputMap(); Object o = map.get(KeyStroke.getKeyStrokeForEvent(ev)); if (o instanceof String) { return (String)o; } else { return null; } }
private void removeWindowsF10() { InputMap imap = menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); Object action = imap.get(KeyStroke.getKeyStroke("F10")); if (log.isInfoEnabled()) log.info("Removing the F10 key from the menuBar's InputMap; it did " + (action == null ? "not" : "") + " exist"); ActionMap amap = menuBar.getActionMap(); amap.getParent().remove(action); }
private void mapWithShift(KeyStroke key) { InputMap inputMap = view.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); Object actionKey = inputMap.get(key); if (actionKey != null) { key = KeyStroke.getKeyStroke(key.getKeyCode(), key.getModifiers() | InputEvent.SHIFT_MASK); view.getInputMap().put(key, actionKey); } }
public static void mapCancelKeystroke( final JDialog dialog, Action cancelAction ) { Object key = dialog.getRootPane().getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).get( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ) ); if( key == null ) { key = "Cancel"; dialog.getRootPane().getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), key ); } dialog.getRootPane().getActionMap().put( key, cancelAction ); }
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; }
static void wrapUpDownArrowActions(JComponent inplaceEditor, final IncrementPropertyValueSupport incrementSupport) { InputMap im = inplaceEditor.getInputMap( JComponent.WHEN_FOCUSED ); wrapAction( im.get(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)), inplaceEditor.getActionMap(), incrementSupport, true ); wrapAction( "selectPrevious", inplaceEditor.getActionMap(), incrementSupport, true ); //NOI18N wrapAction( "selectPrevious2", inplaceEditor.getActionMap(), incrementSupport, true ); //NOI18N wrapAction( im.get(KeyStroke.getKeyStroke(KeyEvent.VK_D, 0)), inplaceEditor.getActionMap(), incrementSupport, false ); wrapAction( "selectNext", inplaceEditor.getActionMap(), incrementSupport, false ); //NOI18N wrapAction( "selectNext2", inplaceEditor.getActionMap(), incrementSupport, false ); //NOI18N }
private Action getHintsPopupAction() { if (isHintsPopupVisible() && getDelegateComponent() != null) { Object key = getDelegateComponent().getInputMap().get(_keyStroke); key = key == null ? getTextComponent().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(_keyStroke) : key; if (key != null) { return getDelegateComponent().getActionMap().get(key); } } return null; }