@Override
    public @NotNull JComponent getKeyComponent(@NotNull JComponent parent) {
      if (myParent == null) {
        parent.addAncestorListener(new AncestorListenerAdapter() {
          @Override
          public void ancestorRemoved(AncestorEvent event) {
            if (myService != null) {
              myService.dispose();
            }
          }
        });
      }
      myParent = parent;
      return super.getKeyComponent(parent);
    }
@Override
    public @NotNull JComponent getKeyComponent(@NotNull JComponent parent)