Java InputMap.remove(KeyStroke key)

Syntax

InputMap.remove(KeyStroke key) has the following syntax.

public void remove(KeyStroke key)

Example

In the following code shows how to use InputMap.remove(KeyStroke key) method.


import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
/*from   w w w  . jav  a2s . co  m*/
public class Main {
  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"));
    
  }
}