sclass PopupMenuMaker { settable bool allowScrolling = true; // ignored when using existingMenu settable MouseEvent 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) { int emptyCount = existingMenu.getComponentCount(); if (addSeparator) existingMenu.addSeparator(); int emptyCount2 = existingMenu.getComponentCount(); fillMenu?.get(existingMenu); if (menu.getComponentCount() == emptyCount2) truncateContainer(menu, emptyCount); printVars("Extended popup menu", +emptyCount, +emptyCount2, n := menu.getComponentCount()); // TODO: revalidate popup? } else { new JPopupMenu menu; int emptyCount = menu.getComponentCount(); fillMenu?.get(menu); if (menu.getComponentCount() == emptyCount) ret; if (allowScrolling && existingMenu == null) { menu = new JPopupMenu; JMenuScroller scroller = JMenuScroller.setScrollerFor(menu); scroller.fillMenu = toVF1(fillMenu); } menu.show(event.getComponent(), event.getX(), event.getY()); } } }