Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1015890 // fillJPopupMenu - see fillJMenu

JavaX fragment (include)

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<S> 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);
  }
}

Author comment

Began life as a copy of #1004035

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1015890
Snippet name: fillJPopupMenu - see fillJMenu
Eternal ID of this version: #1015890/10
Text MD5: 2cb2a1040f660c38212573cb315dab75
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-11 19:05:15
Source code size: 1275 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 481 / 513
Version history: 9 change(s)
Referenced in: [show references]