void (@NotNull Project project, @NotNull Component anchor) { if (myFilterPopup != null || !anchor.isValid()) { return; } JBPopupListener popupCloseListener = new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { myFilterPopup = null; } }; myFilterPopup = JBPopupFactory.getInstance() .createComponentPopupBuilder(createFilterPanel(), null) .setModalContext(false) .setFocusable(false) .setResizable(true) .setCancelOnClickOutside(false) .setMinSize(new Dimension(200, 200)) .setDimensionServiceKey(project, getDimensionServiceKey(), false) .addListener(popupCloseListener) .createPopup(); anchor.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { if (e.getID() == HierarchyEvent.HIERARCHY_CHANGED && !anchor.isValid()) { anchor.removeHierarchyListener(this); if (myFilterPopup != null) { myFilterPopup.cancel(); } } } }); myFilterPopup.showUnderneathOf(anchor); }