public static Window nextWindowAfter (@NotNull Window w) {

    Window[] windows = getWindows(w);

    if (w.equals(windows[windows.length - 1])) {
      return windows[0];
    }

    for (int i = (windows.length - 2); i >= 0; i--) {
      if (w.equals(windows[i])) {
        return windows[i + 1];
      }
    }

    throw new IllegalArgumentException("The window after "  + w.getName() +  " has not been found");
  }
public static Window nextWindowAfter (@NotNull Window w)