KeyStrokes

// Create some keystrokes and bind them all to the same action
component.getInputMap().put(KeyStroke.getKeyStroke("F2"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("control A"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("shift F2"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke('('), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("button3 F"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("typed x"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("released DELETE"), "actionName");
component.getInputMap().put(KeyStroke.getKeyStroke("shift UP"), "actionName");

// Add the action to the component
component.getActionMap().put("actionName",
    new AbstractAction("actionName") {
        public void actionPerformed(ActionEvent evt) {
            process(evt);
        }
    }
);

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.