sclass PopupMenuMaker { settable bool allowScrolling = true; // ignored when using existingMenu settable MouseEvent event; settable PtInComponent ptInComponent; // if different from event settable IVF1 fillMenu; settable JPopupMenu existingMenu; settable bool addSeparator = true; // add separator if existing meun JPopupMenu menu; *() {} *(MouseEvent *event, IVF1 *fillMenu) {} public void run() swing { if (existingMenu != null) { fix(); var menu = existingMenu; int emptyCount = menu.getComponentCount(); if (addSeparator) menu.addSeparator(); int emptyCount2 = menu.getComponentCount(); fillMenu?.get(menu); if (menu.getComponentCount() == emptyCount2) truncateContainer(menu, emptyCount); //printVars("Extended popup menu", +emptyCount, +emptyCount2, n := menu.getComponentCount()); packWindow(menu); //revalidate(menu); } else { new JPopupMenu menu; int emptyCount = menu.getComponentCount(); fillMenu?.get(menu); if (menu.getComponentCount() == emptyCount) ret; if (allowScrolling) { menu = new JPopupMenu; JMenuScroller scroller = JMenuScroller.setScrollerFor(menu); scroller.fillMenu = toVF1(fillMenu); } ptInComponent if null = ptInComponentFromEvent(event); if (hasParentOfType JPopupMenu(ptInComponent.component)) { // component is in a menu itself. TODO: better positioning // Also this doesn't actually seem to work... menu.setInvoker(ptInComponent.component); menu.setVisible(true); } else menu.show(ptInComponent.component, ptInComponent.p.x, ptInComponent.p.y); } } svoid fix { JPopupMenu.setDefaultLightWeightPopupEnabled(false); } }