public static @Nullable UndoManager getUndoManager(Component component) {
    if (component instanceof JTextComponent) {
      Object o = ((JTextComponent)component).getClientProperty(UNDO_MANAGER);
      if (o instanceof UndoManager) {
        return (UndoManager)o;
      }
    }
    return null;
  }
public static @Nullable UndoManager getUndoManager(Component component)