Java tutorial
//package com.java2s; import javax.swing.InputMap; import javax.swing.JComponent; public class Main { public static InputMap installInputMap(JComponent c, InputMap map, int condition) { if (map == null) { return null; } InputMap currentMap = c.getInputMap(condition); if (currentMap != null) { InputMap parent = currentMap; while (parent.getParent() != null) { parent = parent.getParent(); } parent.setParent(map); } else { c.setInputMap(condition, map); } return map; } }