Java Swing KeyStroke removeKeyBinding(JComponent component, String key)

Here you can find the source of removeKeyBinding(JComponent component, String key)

Description

remove Key Binding

License

Open Source License

Declaration

public static void removeKeyBinding(JComponent component, String key) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.InputMap;

import javax.swing.JComponent;

import javax.swing.KeyStroke;

public class Main {
    public static void removeKeyBinding(JComponent component, String key) {
        int condition = JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;
        InputMap inputMap = component.getInputMap(condition);
        // According to the docs, null should remove the action, but it does
        // not seem to work with Sun Java 1.4.2, new Object() works
        inputMap.put(KeyStroke.getKeyStroke(key), new Object());
    }/*from w  ww.  j a  v  a  2 s  .  c  om*/
}

Related

  1. registerTabKey(Container container)
  2. removeAcceleratorFromChildren(Container container, KeyStroke accelerator)
  3. removeAcceleratorFromComponent(JComponent component, KeyStroke accelerator)
  4. removeAcceleratorFromMap(InputMap map, KeyStroke accelerator)
  5. removeButtonClickKeystroke(AbstractButton b, KeyStroke key)
  6. removeKeyCode(JComponent comp, int keyCode)
  7. removeShortcut(JRootPane rootPane, String command, KeyStroke stroke)
  8. setAcceleratorKey(Action action, KeyStroke acceleratorKey)
  9. setActionKeyBinding(final JComponent component, final int condition, final KeyStroke keyStroke, final Action action)