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).

svoid inputText(S msg, S defaultText, IVF1<S> action) {
  inputText(msg, defaultText, (O) action);
}

svoid inputText(S msg, IVF1<S> action) {
  inputText(msg, (O) action);
}

// legacy signatures

svoid inputText(S msg, O action) {
  inputText(msg, "", action);
}

// action: voidfunc(S)
svoid inputText(S msg, S defaultText, O action) {
  fO threadInfo = _threadInfo();
  awt {
    final JTextField tf = jtextfield(defaultText);
    S title = joinNemptiesWithVBar(msg, programNameOrNull());
    JComponent form = showFormTitled(title,
      unnull(msg), tf,
      r {
        vmBus_send('inputtingText_OK, threadInfo, msg, tf);
        callF_thread(action, getTextTrim(tf))
      });
    renameSubmitButton(form, "OK");
    vmBus_send('inputtingText, threadInfo, msg, tf);
  }
}

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: 432 / 524
Version history: 11 change(s)
Referenced in: [show references]