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

24
LINES

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

JavaX fragment (include)

static void inputText(fS msg, fO action) {
  inputText(msg, "", action);
}

// action: voidfunc(S)
svoid inputText(fS msg, final S defaultText, fO action) {
  fO threadInfo = _threadInfo();
  awt {
    final JTextField tf = jtextfield(defaultText);
    S title = joinStrings(" | ", msg, programName());
    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);
  }
}

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

Author comment

Began life as a copy of #1006692

download  show line numbers  debug dex   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

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/9
Text MD5: 817fdd7df8279b17068f16f4caf7656a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-14 00:16:52
Source code size: 715 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 178
Version history: 8 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1014599 & http://1014599.tinybrain.de