private static Component getFrameOrDialog(Component component) {
    while (component != null) {
      if (component instanceof Window) return component;
      component = UIUtil.getParent(component);
    }
    return null;
  }
private static Component getFrameOrDialog(Component component)