Here you can find the source of addKeyBinding(JComponent comp, KeyStroke key, String id, Action action)
public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action)
//package com.java2s; //License from project: Apache License import javax.swing.Action; import javax.swing.JComponent; import javax.swing.KeyStroke; public class Main { public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action) { comp.getInputMap().put(key, id); comp.getActionMap().put(id, action); }//from w ww. j a v a 2 s . c o m }