void (Component comp, int x, int y) { if (Boolean.TRUE.equals(ClientProperty.get(comp, DISABLE_CUSTOMIZE_POPUP_KEY))) { return; } ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(place, customizationGroup); popupMenu.setTargetComponent(component); JPopupMenu menu = popupMenu.getComponent(); menu.addPopupMenuListener(new PopupMenuListenerAdapter() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Object obj = e.getSource(); JBPopupMenu menu = obj instanceof JBPopupMenu ? (JBPopupMenu)obj : null; popupInvoker.set(menu == null ? null : menu.getInvoker()); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { ApplicationManager.getApplication().invokeLater(() -> { popupInvoker.set(null); }); } }); menu.show(comp, x, y); }