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

23
LINES

< > BotCompany Repo | #1016854 // CollectIOExamples [Include]

JavaX fragment (include)

1  
abstract sclass CollectIOExamples > DynModule {
2  
  new L<Example> examples;
3  
  transient JList examplesList;
4  
  
5  
  srecord Example(S question, S answer) { toString { ret question + " -> " + answer; } }
6  
  
7  
  JComponent visualize() {
8  
    ret withCenteredButtons(listPopupMenuThreaded(examplesList = jLiveValueList(dm_fieldLiveValue('examples)), "Delete Example", voidfunc(S row) {
9  
      temp enter(); setField(examples := listMinusToString(examples, row))
10  
    }), buttons());
11  
  }
12  
  
13  
  O[] buttons() {
14  
    ret litobjectarray("Add example...", rThread addExampleDialog);
15  
  }
16  
  
17  
  void addExampleDialog {
18  
    final JTextField tfQuestion = jtextfield(), tfAnswer = jtextfield("?");
19  
    showFormTitled("Add example", "Question:", tfQuestion, "Answer (if known):", tfAnswer, r {
20  
      temp enter(); setField(examples := listPlus(examples, new Example(gtt(tfQuestion), gtt(tfAnswer))));
21  
    });
22  
  }
23  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016854
Snippet name: CollectIOExamples [Include]
Eternal ID of this version: #1016854/5
Text MD5: 3ee9634f769e7309534c3f7f20cf468b
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-24 04:16:47
Source code size: 910 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 397 / 963
Version history: 4 change(s)
Referenced in: [show references]