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

56
LINES

< > BotCompany Repo | #1014713 // showForm_makeComponents

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9546L/55K).

1  
static LL<JComponent> showForm_makeComponents(Bool internalFrame, O... _parts) {
2  
  IVF1<Component> closeFrame
3  
    = isTrue(internalFrame)
4  
      ? l1 disposeInternalFrame
5  
    : isFalse(internalFrame)
6  
      ? l1 disposeFrame
7  
    : null;
8  
9  
  ret showForm_makeComponents(closeFrame, _parts);
10  
}
11  
12  
static LL<JComponent> showForm_makeComponents(IVF1<Component> closeFrame, O... _parts) {
13  
14  
  new LL<JComponent> l;
15  
  L parts = asList(_parts);
16  
  JButton submitButton = null;
17  
  
18  
  for i over parts:
19  
    if (parts.get(i) instanceof Swingable)
20  
      parts.set(i, ((Swingable) parts.get(i)).visualize());
21  
      
22  
  for i over parts: {
23  
    O o = parts.get(i), next = get(parts, i+1);
24  
    if (o instanceof S && next instanceof Component)
25  
      setComponentID((Component) next, (S) o);
26  
    
27  
    if (o instanceof Component || o instanceof S || next instanceof Component) { // smartAdd accepts strings
28  
      l.add(mapLL wrapForSmartAdd_jComponent(
29  
          o == null ? new JPanel
30  
        : o instanceof S ? humanizeFormLabel((S) o)
31  
        : o, next));
32  
      if (next instanceof JButton && submitButton == null)
33  
        submitButton = (JButton) next;
34  
      i++;
35  
    } else if (isRunnable(o))
36  
      l.add(mapLL wrapForSmartAdd_jComponent(null, submitButton = jbutton(showFormSubmitButtonName(), r {
37  
        O result = call(o);
38  
        print("Result of form runnable: " + result + ". Button:  " + heldInstance(JButton));
39  
        if (neq(Bool.FALSE, result))
40  
          closeFrame?.get(heldInstance(JButton));
41  
      })));
42  
    else print("showForm: Unknown element type: " + getClassName(o));
43  
  }
44  
  if (submitButton != null) {
45  
    final JButton _submitButton = submitButton;
46  
    onEnterInAllTextFields(concatLists(l), r { clickButton(_submitButton) });
47  
  }
48  
  
49  
  // massage labels
50  
  for (L<JComponent> row : l) {
51  
    JComponent left = first(row);
52  
    if (left instanceof JLabel) makeBold((JLabel) left).setVerticalAlignment(JLabel.TOP);
53  
  }
54  
  
55  
  ret l;
56  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014713
Snippet name: showForm_makeComponents
Eternal ID of this version: #1014713/25
Text MD5: 843a7b78185773fd0d95301a30c17a72
Transpilation MD5: 3cf435311f5fbefad36a9decc399379a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-29 16:01:31
Source code size: 1982 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 522 / 636
Version history: 24 change(s)
Referenced in: [show references]