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

33
LINES

< > BotCompany Repo | #1035073 // JForm - create a Swing form

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

Libraryless. Click here for Pure Java version (16440L/96K).

1  
// Note: Putting a JForm in a scroll pane is still under development
2  
// jscroll_vertical seems to work, at least if there are no tall components
3  
// (text areas).
4  
5  
sclass JForm is Swingable {
6  
  new L parts;
7  
  new FormLayout1 layout;
8  
  JPanel panel;
9  
  settable bool scrollable;
10  
  
11  
  // called after form is submitted.
12  
  // can set or change at any point after form is generated/shown
13  
  settable IVF1<Component> frameCloser;
14  
  
15  
  *(O... parts) { this.parts = asList(parts); }
16  
  
17  
  selfType addRow(S label, Component etc component) {
18  
    addAll(parts, label, component);
19  
    this;
20  
  }
21  
  
22  
  cachedVisualize {
23  
    panel = jpanel(layout,
24  
      showForm_arrange1(showForm_makeComponents(
25  
        c -> { frameCloser?.get(c); },
26  
        flattenToArray(parts))));
27  
    ret scrollable ? jscroll_vertical(panel) : panel;
28  
  }
29  
        
30  
  selfType closeInternalFrameOnSubmit() { frameCloser(l1 disposeInternalFrame); this; }
31  
  selfType closeFrameOnSubmit aka disposeFrameOnSubmit() { frameCloser(l1 disposeFrame); this; }
32  
  selfType closeNothingOnSubmit() { frameCloser(null); this; }
33  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035073
Snippet name: JForm - create a Swing form
Eternal ID of this version: #1035073/13
Text MD5: 199032cba7df8d99de2191d8340f7f57
Transpilation MD5: 37b1f3c92b9b97abf7d21c2ca5fb3c47
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-13 21:27:10
Source code size: 1101 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 217 / 348
Version history: 12 change(s)
Referenced in: [show references]