static void fillJPopupMenu(JPopupMenu m, O... x) { if (x == null) ret; for i over x: { O o = x[i], y = get(x, i+1); ifdef fillJPopupMenu_debug print("fillJPopupMenu: " + x); endifdef if (o instanceof IVF1) callF(o, m); else if (o instanceof L) fillJPopupMenu(m, asArray((L) o)); else if (isMenuSeparatorIndicator(o)) m.addSeparator(); ifclass LiveValue else if (o instanceof LiveValue && o/LiveValue.getType() == S.class && isRunnableX(y)) { final LiveValue lv = cast o; final JMenuItem mi = jmenuItem("", y); bindLiveValueListenerToComponent(mi, lv, r { S s = lv!; if (isCurlyBracketed(s)) { setEnabled(mi, false); s = unCurlyBracket(s); } else setEnabled(mi, true); setText(mi, s); }); m.add(mi); } endif else if (o instanceof S && isRunnableX(y)) { m.add(jmenuItem((S) o, y)); ++i; } else if (o instanceof JMenuItem) m.add((JMenuItem) o); // "call" might use wrong method else if (o instanceof S || o instanceof Action || o instanceof Component) call(m, "add", o); else if (o != null) print("Unknown menu item: " + o); } }