ChangeInputMap

InputMap inputMap = new InputMap();

// Add a KeyStroke
inputMap.put(KeyStroke.getKeyStroke("F2"), "actionName");

inputMap.setParent(component.getInputMap(JComponent.WHEN_FOCUSED));
component.setInputMap(JComponent.WHEN_FOCUSED, inputMap);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.