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

30
LINES

< > BotCompany Repo | #1014599 // inputText - show input form for single-line text, call action on enter (in new thread)

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

Libraryless. Click here for Pure Java version (16174L/97K).

1  
svoid inputText(S msg, S defaultText, IVF1<S> action) {
2  
  inputText(msg, defaultText, (O) action);
3  
}
4  
5  
svoid inputText(S msg, IVF1<S> action) {
6  
  inputText(msg, (O) action);
7  
}
8  
9  
// legacy signatures
10  
11  
svoid inputText(S msg, O action) {
12  
  inputText(msg, "", action);
13  
}
14  
15  
// action: voidfunc(S)
16  
svoid inputText(S msg, S defaultText, O action) {
17  
  fO threadInfo = _threadInfo();
18  
  awt {
19  
    final JTextField tf = jtextfield(defaultText);
20  
    S title = joinNemptiesWithVBar(msg, programNameOrNull());
21  
    JComponent form = showFormTitled(title,
22  
      unnull(msg), tf,
23  
      r {
24  
        vmBus_send('inputtingText_OK, threadInfo, msg, tf);
25  
        callF_thread(action, getTextTrim(tf))
26  
      });
27  
    renameSubmitButton(form, "OK");
28  
    vmBus_send('inputtingText, threadInfo, msg, tf);
29  
  }
30  
}

Author comment

Began life as a copy of #1006692

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: #1014599
Snippet name: inputText - show input form for single-line text, call action on enter (in new thread)
Eternal ID of this version: #1014599/12
Text MD5: f79ded2429016ac9a5bb1feaadb822a2
Transpilation MD5: 9d2dbdcd158214012f2de4ebc03a4aa4
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-07 19:23:48
Source code size: 809 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 536 / 667
Version history: 11 change(s)
Referenced in: [show references]