@Override
    public void eventDispatched(final AWTEvent event) {
      switch (event.getID()) {
        case WINDOW_ACTIVATED, WINDOW_GAINED_FOCUS -> {
          if (myCancelOnWindow && myPopup != null && isCancelNeeded((WindowEvent)event, myPopup.getWindow())) {
            ApplicationManager.getApplication().invokeLater(() ->cancel());
          }
        }
        case MOUSE_ENTERED -> {
          if (withinPopup(event)) {
            myEverEntered = true;
          }
        }
        case MOUSE_MOVED, MOUSE_PRESSED -> {
          if (myCancelOnMouseOutCallback != null && myEverEntered && !withinPopup(event)) {
            if (myCancelOnMouseOutCallback.check((MouseEvent)event)) {
              cancel();
            }
          }
        }
      }
    }
@Override
    public void eventDispatched(final AWTEvent event)