List of usage examples for javax.swing InputMap remove
public void remove(KeyStroke key)
From source file:Main.java
public static void main(String[] argv) throws Exception { InputMap inputMap = new InputMap(); inputMap.put(KeyStroke.getKeyStroke("F2"), "actionName"); JButton component = new JButton("button"); inputMap.setParent(component.getInputMap(JComponent.WHEN_FOCUSED)); component.setInputMap(JComponent.WHEN_FOCUSED, inputMap); inputMap.remove(KeyStroke.getKeyStroke("F2")); }
From source file:Main.java
public static void updateMnemonic(JComponent c, int oldKey, int newKey) { if (oldKey == newKey) { return;// www. j a va 2s . c o m } InputMap map = c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null && oldKey != 0) { map.remove(KeyStroke.getKeyStroke(oldKey, KeyEvent.ALT_MASK)); } if (newKey != 0) { if (map == null) { map = new ComponentInputMap(c); c.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); } map.put(KeyStroke.getKeyStroke(newKey, KeyEvent.ALT_MASK), "press"); } }
From source file:Main.java
public static void updateToggleMnemonic(JComponent c, int oldKey, int newKey) { if (oldKey == newKey) { return;//from w w w . j ava 2 s .c o m } InputMap map = c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null && oldKey != 0) { map.remove(KeyStroke.getKeyStroke(oldKey, KeyEvent.ALT_MASK, false)); map.remove(KeyStroke.getKeyStroke(oldKey, KeyEvent.ALT_MASK, true)); map.remove(KeyStroke.getKeyStroke(oldKey, KeyEvent.VK_UNDEFINED, true)); } if (newKey != 0) { if (map == null) { map = new ComponentInputMap(c); c.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); } map.put(KeyStroke.getKeyStroke(newKey, KeyEvent.ALT_MASK, false), "press"); map.put(KeyStroke.getKeyStroke(newKey, KeyEvent.ALT_MASK, true), "release"); map.put(KeyStroke.getKeyStroke(newKey, KeyEvent.VK_UNDEFINED, true), "release"); } }
From source file:Main.java
public static void updateAccelerator(JMenuItem menuItem, KeyStroke oldAccelerator) { KeyStroke accelerator = menuItem.getAccelerator(); if (oldAccelerator != null && oldAccelerator.equals(accelerator)) { return;// w w w. j av a2 s . c o m } InputMap map = menuItem.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null && oldAccelerator != null) { map.remove(oldAccelerator); } if (accelerator != null) { if (map == null) { map = new ComponentInputMap(menuItem); menuItem.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); } map.put(accelerator, "click"); } }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Moves the action for the specified character from the 'ctrl' mask * to the 'meta' mask./* w w w . jav a2s . c om*/ */ private static void replaceAction(InputMap map, char c) { KeyStroke ctrl = KeyStroke.getKeyStroke("control pressed " + c); KeyStroke meta = KeyStroke.getKeyStroke("meta pressed " + c); if (ctrl == null || meta == null) return; Object action = map.get(ctrl); if (action != null) { map.remove(ctrl); map.put(meta, action); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFrameActionsHolder.java
public void removeAction(Action action) { if (actionList.remove(action)) { if (action.getShortcutCombination() != null) { InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = panel.getActionMap(); KeyStroke keyStroke = shortcutActions.get(action); if (keyStroke != null) { inputMap.remove(keyStroke); actionMap.remove(action.getId()); }//ww w.j a v a2 s. co m } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopPickerField.java
protected void updateOrderedShortcuts() { InputMap inputMap = getImpl().getInputField().getInputMap(JComponent.WHEN_FOCUSED); for (int i = 0; i < 9; i++) { KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, modifiersMask, false); inputMap.remove(keyStroke); }//from www . ja v a 2s . co m int index = 0; for (Action action : actionsOrder) { KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_1 + index, modifiersMask, false); List<KeyStroke> keyStrokes = new LinkedList<>(); keyStrokes.add(keyStroke); keyStrokesMap.put(action, keyStrokes); inputMap.put(keyStroke, action.getId()); index++; } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopPickerField.java
@Override public void removeAction(@Nullable Action action) { if (action != null) { if (actionsOrder.remove(action)) { if (action.getOwner() != null && action.getOwner() instanceof DesktopButton) { JButton button = ((DesktopButton) action.getOwner()).getImpl(); impl.removeButton(button); }/*from w ww.j av a 2 s . c om*/ InputMap inputMap = getImpl().getInputField().getInputMap(JComponent.WHEN_FOCUSED); ActionMap actionMap = getImpl().getInputField().getActionMap(); List<KeyStroke> keyStrokes = keyStrokesMap.get(action); if (keyStrokes != null) { for (KeyStroke keyStroke : keyStrokes) { inputMap.remove(keyStroke); } actionMap.remove(action.getId()); } updateOrderedShortcuts(); } } }
From source file:org.executequery.gui.editor.autocomplete.QueryEditorAutoCompletePopupProvider.java
private void resetEditorActions() { JTextComponent textComponent = queryEditorTextComponent(); ActionMap actionMap = textComponent.getActionMap(); actionMap.remove(LIST_FOCUS_ACTION_KEY); actionMap.remove(LIST_SELECTION_ACTION_KEY); actionMap.remove(LIST_SCROLL_ACTION_KEY_DOWN); actionMap.remove(LIST_SCROLL_ACTION_KEY_UP); InputMap inputMap = textComponent.getInputMap(); inputMap.remove(KEY_STROKE_DOWN); inputMap.remove(KEY_STROKE_UP);//from w w w. j a va 2s .c o m inputMap.remove(KEY_STROKE_PAGE_DOWN); inputMap.remove(KEY_STROKE_PAGE_UP); inputMap.remove(KEY_STROKE_ENTER); inputMap.remove(KEY_STROKE_TAB); inputMap.put(KEY_STROKE_DOWN, existingKeyStrokeDownAction); inputMap.put(KEY_STROKE_UP, existingKeyStrokeUpAction); inputMap.put(KEY_STROKE_PAGE_DOWN, existingKeyStrokePageDownAction); inputMap.put(KEY_STROKE_PAGE_UP, existingKeyStrokePageUpAction); inputMap.put(KEY_STROKE_TAB, existingKeyStrokeTabAction); inputMap.put(KEY_STROKE_ENTER, existingKeyStrokeEnterAction); textComponent.removeCaretListener(this); }