while(child.getParent() != null && !(child.getParent() instanceof InputMapUIResource)) child = child.getParent(); if (child != null)
InputMap parent = child.getParent(); while (parent != null && !(parent instanceof InputMapUIResource)) { child = parent; parent = parent.getParent(); }
  public static void replaceUIInputMap(JComponent component,                                        int condition,                                        InputMap uiInputMap)  {    InputMap child = component.getInputMap(condition);    if (child == null)      component.setInputMap(condition, uiInputMap);    else      {        while(child.getParent() != null              && !(child.getParent() instanceof InputMapUIResource))          child = child.getParent();        if (child != null)          child.setParent(uiInputMap);      }  }