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

35
LINES

< > BotCompany Repo | #1000919 // Swing: Answer a question

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2002L/15K/48K).

!747

m {
  static S answererID = "#1000887";
  static S defaultQuestion = "";
  static S q, answer;
  
  p {
    if (args.length != 0) answererID = smartJoin(args);
    thread { // because slte must be called in non-awt thread
      while (true) {
        S text;
        if (answer != null) {
          text = q + "\n" + formatSnippetID(answererID) + ": " + answer;
          defaultQuestion = q;
        } else
          text = "Hi! What's your question for " + formatSnippetID(answererID) + "?";
        q = slte(text, defaultQuestion);
        if (q == null) {
          print("abort");
          killMyself();
        } else {
          print("Answering: " + q);
          
          try {
            Class prog = hotwire(answererID);
            set(prog, "question", q);
            callMain(prog);
            answer = (S) get(prog, "answer");
          } catch (Throwable e) { popup(e); }
        }
      }
    }
  }
}

Author comment

Began life as a copy of #1000917

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000919
Snippet name: Swing: Answer a question
Eternal ID of this version: #1000919/1
Text MD5: 807458924490267759b9e558441256ee
Transpilation MD5: 6a367f645aa53adcf3bd6e12bc2a5938
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-08 20:06:20
Source code size: 963 bytes / 35 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 583 / 591
Referenced in: [show references]