//please include function withMargin. static int showForm_defaultGap = 4; static JPanel showFormTitled(fS title, fO... _parts) { ret swing(func -> JPanel { final new Var<JFrame> frame; JPanel panel = showForm_makePanel(frame, _parts); frame.set(handleEscapeKey(minFrameWidth(showPackedFrame(title, withMargin(panel)), 400))); ret panel; }); } static JPanel showForm_makePanel(final Var<JFrame> frame, O... _parts) { new L<L> l; L parts = asList(_parts); Runnable submit = null; for (int i = 0; i < l(parts); i++) { final O o = parts.get(i), next = get(parts, i+1); if (o instanceof Component || o instanceof S || next instanceof Component) { // smartAdd accepts strings l.add(ll(o == null ? new JPanel : o, next)); if (next instanceof JButton && submit == null) submit = r { ((JButton) next).doClick() }; i++; } else if (isRunnable(o)) l.add(ll(null, jbutton(showFormSubmitButtonName(), submit = r { O result = call(o); if (neq(Boolean.FALSE, result)) disposeFrame(frame.get()); }))); else print("showForm: Unknown element type: " + getClassName(o)); } JPanel panel = hvgrid((L) l, showForm_defaultGap); if (submit != null) for (JTextField textField : childrenOfType(panel, JTextField.class)) onEnter(textField, submit); ret panel; }
Began life as a copy of #1004442
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014701 |
Snippet name: | showFormTitled (+ showForm_makePanel) - show input form [Swing, v1 with hvgrid] |
Eternal ID of this version: | #1014701/1 |
Text MD5: | 5405cf81dec6cede53a25c9409fdc411 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-30 17:24:40 |
Source code size: | 1399 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 378 / 427 |
Referenced in: | -