Here you can find the source of clearActionBinding(final JComponent component, final KeyStroke keyStroke, final int condition)
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)) |
public static void clearActionBinding(final JComponent component, final KeyStroke keyStroke, final int condition)
//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(); } } }