Java Swing KeyStroke clearActionBinding(final JComponent component, final KeyStroke keyStroke, final int condition)

Here you can find the source of clearActionBinding(final JComponent component, final KeyStroke keyStroke, final int condition)

Description

Clears the action key registered under the given keystroke.

License

Apache License

Parameter

Parameter Description
component Component which's action binding should be cleared.
keyStroke Keystroke triggering the binding to be removed,
condition The condition for the input map (as you would pass to JComponent#getInputMap(int))

Declaration

public static void clearActionBinding(final JComponent component, final KeyStroke keyStroke,
        final int condition) 

Method Source Code

//package com.java2s;
/**//from w w  w  .  j ava  2 s.  com
 * todo [heup] add docs <hr/> Copyright 2006-2012 Torsten Heup
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

import javax.swing.*;

public class Main {
    /**
     * Clears the action key registered under the given keystroke. The action itself will remain in the component's
     * action map, only the binding from the input map will be removed.
     *
     * @param component Component which's action binding should be cleared.
     * @param keyStroke Keystroke triggering the binding to be removed,
     * @param condition The condition for the input map (as you would pass to JComponent#getInputMap(int))
     */
    public static void clearActionBinding(final JComponent component, final KeyStroke keyStroke,
            final int condition) {
        InputMap map = component.getInputMap(condition);
        while (map != null) {
            map.remove(keyStroke);
            map = map.getParent();
        }
    }
}

Related

  1. addShortcutToComponent(final JComponent component, final KeyStroke keystroke, final String actionCommand, final Action action)
  2. addShortcutToComponent(JComponent component, KeyStroke keystroke, String actionCommand, Action action)
  3. bindAction(JComponent aComponent, String aCommand, Action anAction, KeyStroke aKeyStroke)
  4. bindKeyToAction(int keyCode, int modifiers, Action action, JComponent component, int condition)
  5. bindKeyToAction(JComponent c, KeyStroke key, Action a)
  6. clearKeyStroke(JComponent component)
  7. closeOnKeyStroke(JRootPane rootPane, KeyStroke keyStroke)
  8. componentListensForKey(JComponent component, int keyCode)
  9. configAction(Action action, String text, Icon icon, KeyStroke keyStroke)