KeyStroke stroke = (KeyStroke) keys[i]; String actionString = (String) focusInputMap.get(stroke); parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString);
am = new ActionMapUIResource(); ListAction action; action = new ListAction("selectPreviousRow"); am.put("selectPreviousRow", action); action = new ListAction("selectNextRow"); am.put("selectNextRow", action); action = new ListAction("selectPreviousRowExtendSelection"); am.put("selectPreviousRowExtendSelection", action); action = new ListAction("selectNextRowExtendSelection"); am.put("selectNextRowExtendSelection", action);
  protected void installKeyboardActions()  {    InputMap focusInputMap = (InputMap) UIManager.get("List.focusInputMap");    InputMapUIResource parentInputMap = new InputMapUIResource();    // FIXME: The JDK uses a LazyActionMap for parentActionMap    ActionMap parentActionMap = new ActionMapUIResource();    action = new ListAction();    Object keys[] = focusInputMap.allKeys();    // Register key bindings in the UI InputMap-ActionMap pair    for (int i = 0; i < keys.length; i++)      {        KeyStroke stroke = (KeyStroke) keys[i];        String actionString = (String) focusInputMap.get(stroke);        parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),                                                  stroke.getModifiers()),                           actionString);        parentActionMap.put(actionString,                              new ActionListenerProxy(action, actionString));      }    // Register the new InputMap-ActionMap as the parents of the list's    // InputMap and ActionMap    parentInputMap.setParent(list.getInputMap().getParent());    parentActionMap.setParent(list.getActionMap().getParent());    list.getInputMap().setParent(parentInputMap);    list.getActionMap().setParent(parentActionMap);  }