static AutoCloseable tempGlobalPopupMenu(IVF2 fillMenu, double delay default 0.1) { ret fillMenu == null ?: tempAddPopupButtonListener(evt -> { var c = evt.getComponent(); if (c == null) ret; // It's a tray icon popup var c2 = SwingUtilities.getDeepestComponentAt(c, evt.getX(), evt.getY()); var p = ptInComponentFromEvent(evt); var p2 = translateLocationBetweenComponents(p, c2); awtLater(delay, r { var menu = currentPopupMenu(); print("Pimping popup menu " + menu); new PopupMenuMaker maker; maker.ptInComponent(p2); maker.event(evt).existingMenu(menu).fillMenu( _menu -> fillMenu.get(c2, _menu)).run(); }); }); }