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)

1  
static void fillJPopupMenu(JPopupMenu m, O... x) {
2  
  if (x == null) ret;
3  
  for i over x: {
4  
    O o = x[i], y = get(x, i+1);
5  
    ifdef fillJPopupMenu_debug
6  
      print("fillJPopupMenu: " + x);
7  
    endifdef
8  
    if (o instanceof IVF1)
9  
      callF(o, m);
10  
    else if (o instanceof L)
11  
      fillJPopupMenu(m, asArray((L) o));
12  
    else if (isMenuSeparatorIndicator(o))
13  
      m.addSeparator();
14  
    ifclass LiveValue
15  
    else if (o instanceof LiveValue && o/LiveValue.getType() == S.class && isRunnableX(y)) {
16  
      final LiveValue<S> lv = cast o;
17  
      final JMenuItem mi = jmenuItem("", y);
18  
      bindLiveValueListenerToComponent(mi, lv, r {
19  
        S s = lv!;
20  
        if (isCurlyBracketed(s)) {
21  
          setEnabled(mi, false);
22  
          s = unCurlyBracket(s);
23  
        } else
24  
          setEnabled(mi, true);
25  
        setText(mi, s);
26  
      });
27  
      m.add(mi);
28  
    }
29  
    endif
30  
    else if (o instanceof S && isRunnableX(y)) {
31  
      m.add(jmenuItem((S) o, y));
32  
      ++i;
33  
    } else if (o instanceof JMenuItem)
34  
      m.add((JMenuItem) o); // "call" might use wrong method
35  
    else if (o instanceof S || o instanceof Action || o instanceof Component)
36  
      call(m, "add", o);
37  
    else if (o != null)
38  
      print("Unknown menu item: " + o);
39  
  }
40  
}

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: 482 / 515
Version history: 9 change(s)
Referenced in: [show references]