Here you can find the source of addShortcut(JRootPane rootPane, String command, Action action)
public static void addShortcut(JRootPane rootPane, String command, Action action)
//package com.java2s; //License from project: Apache License import javax.swing.*; public class Main { public static void addShortcut(JRootPane rootPane, String command, Action action) { KeyStroke stroke = KeyStroke.getKeyStroke(command); addShortcut(rootPane, command, action, stroke); }/*from w ww .j a va 2 s .co m*/ public static void addShortcut(JRootPane rootPane, String command, Action action, KeyStroke stroke) { InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(stroke, command); rootPane.getActionMap().put(command, action); } }