Disposable (@NotNull JBPopup popup) { Disposable disposable = Disposer.newDisposable(); Disposer.register(popup, disposable); popup.addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { Disposer.dispose(disposable); } }); return disposable; }