List of usage examples for javax.swing JMenuItem setInputMap
public final void setInputMap(int condition, InputMap map)
InputMap
to use under the condition condition
to map
. From source file:Main.java
public static void updateAccelerator(JMenuItem menuItem, KeyStroke oldAccelerator) { KeyStroke accelerator = menuItem.getAccelerator(); if (oldAccelerator != null && oldAccelerator.equals(accelerator)) { return;/*from w w w . j a va 2 s . c om*/ } InputMap map = menuItem.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null && oldAccelerator != null) { map.remove(oldAccelerator); } if (accelerator != null) { if (map == null) { map = new ComponentInputMap(menuItem); menuItem.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); } map.put(accelerator, "click"); } }