private static void fitToVisibleArea(Rectangle targetBounds) {
    if (StartupUiUtil.isWaylandToolkit()) return; // Wrt screen edges, only the Wayland server can reliably position popups

    Point topLeft = new Point(targetBounds.x, targetBounds.y);
    Point bottomRight = new Point((int)targetBounds.getMaxX(), (int)targetBounds.getMaxY());
    Rectangle topLeftScreen = ScreenUtil.getScreenRectangle(topLeft);
    Rectangle bottomRightScreen = ScreenUtil.getScreenRectangle(bottomRight);
    if (topLeft.x < topLeftScreen.x || topLeft.y < topLeftScreen.y
        || bottomRight.x > bottomRightScreen.getMaxX() || bottomRight.y > bottomRightScreen.getMaxY()) {
      GraphicsDevice device = ScreenUtil.getScreenDevice(targetBounds);
      Rectangle mostAppropriateScreenRectangle = device != null ? ScreenUtil.getScreenRectangle(device.getDefaultConfiguration())
                                                                : ScreenUtil.getMainScreenBounds();
      ScreenUtil.moveToFit(targetBounds, mostAppropriateScreenRectangle, null);
    }
  }
private static void fitToVisibleArea(Rectangle targetBounds)