while(child.getParent() != null && !(child.getParent() instanceof ActionMapUIResource)) child = child.getParent();
ActionMap parent = child.getParent(); while(parent != null) { child = parent; parent = child.getParent(); }
  public static void replaceUIActionMap(JComponent component,                                         ActionMap uiActionMap)  {    ActionMap child = component.getActionMap();    if (child == null)      component.setActionMap(uiActionMap);    else      {        while(child.getParent() != null              && !(child.getParent() instanceof ActionMapUIResource))          child = child.getParent();        if (child != null)          child.setParent(uiActionMap);      }  }