void (@Nullable String dimensionKey) { Window popupWindow = getPopupWindow(); if (popupWindow == null) return; ComponentListener windowListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (myShown) { processOnSizeChanged(); } } }; popupWindow.addComponentListener(windowListener); addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { popupWindow.removeComponentListener(windowListener); } }); }