InputMap input = getInputMap(); ActionMap actions = getActionMap();  Container parent = getParent(); while ((parent != null) && (parent instanceof JComponent)) { JComponent jParent = (JComponent) parent; InputMap parentInput = jParent.getInputMap(); ActionMap parentAction = jParent.getActionMap();  KeyStroke[] ikeys = input.allKeys(); for (int i = 0; i < ikeys.length; i++) { parentInput.remove(ikeys[i]); }  Object[] akeys = actions.allKeys(); for (int i = 0; i < akeys.length; i++) { parentAction.remove(akeys[i]); }  parent = jParent.getParent(); }
KeyboardManager.getManager().clearBindingsForComp(this);
  public void removeNotify()  {    super.removeNotify();    // let parents inherit the keybord mapping    InputMap input = getInputMap();    ActionMap actions = getActionMap();    Container parent = getParent();    while ((parent != null) && (parent instanceof JComponent))      {        JComponent jParent = (JComponent) parent;        InputMap parentInput = jParent.getInputMap();        ActionMap parentAction = jParent.getActionMap();        KeyStroke[] ikeys = input.allKeys();        for (int i = 0; i < ikeys.length; i++)          {            parentInput.remove(ikeys[i]);          }        Object[] akeys = actions.allKeys();        for (int i = 0; i < akeys.length; i++)          {            parentAction.remove(akeys[i]);          }        parent = jParent.getParent();      }    // Notify ancestor listeners.    fireAncestorEvent(this, AncestorEvent.ANCESTOR_REMOVED);    // fire property change event for 'ancestor'    firePropertyChange("ancestor", parent, null);  }