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

25
LINES

< > BotCompany Repo | #1006588 // autoCompleteTextField [dev.]

JavaX fragment (include)

1  
sclass AutoCompleter {
2  
  void addValue(S s) {}
3  
  S completeInput(S s) { ret ""; }
4  
}
5  
6  
sclass LocalAutoCompleter {
7  
  new TreeSet<S> entries;
8  
  
9  
  void addValue(S s) { entries.add(s); }
10  
  
11  
  S completeInput(S s) {
12  
    S completion = firstStartingWith(entries, s);
13  
    ret completion != null ? dropPrefix(s, completion) : "";
14  
  }
15  
}
16  
17  
static JTextField autoCompleteTextField(JTextField tf) {
18  
  final new LocalAutoCompleter completer;
19  
  onEnter(tf, r {
20  
    completer.addValue(tf.getText());
21  
  });
22  
  /*onComponentHide(tf, r {
23  
    completer.addValue();
24  
  );*/
25  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006588
Snippet name: autoCompleteTextField [dev.]
Eternal ID of this version: #1006588/1
Text MD5: e3fc20d29bbf661cf244727b1a2d8ae7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-20 16:01:16
Source code size: 576 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 524 / 556
Referenced in: [show references]