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

33
LINES

< > BotCompany Repo | #1016970 // Remember Words Seen In Any Swing Component

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14690L/101K).

1  
!7
2  
3  
sclass RememberAllWords > DynPrintLog {
4  
  new LinkedHashSet<S> wordSet;
5  
  int interval = 10000;
6  
  
7  
  void start {
8  
    print("Got " + n2(l(wordSet), "word"));
9  
    doEvery(interval, r doIt);
10  
    if (syncEmpty(wordSet)) doIt();
11  
  }
12  
  
13  
  void doIt {
14  
    temp enter();
15  
    please include function getText.
16  
17  
    new Set<S> wordsOnScreen;
18  
    
19  
    for (Component c : allComponentsInWindows()) {
20  
      S text = (S) callOpt(mc(), 'getText, c); // Reflection abuse!
21  
      addAll(wordsOnScreen, words2_notNextToNumbers(text));
22  
    }
23  
    
24  
    Collection<S> newWords = setMinusSet_syncOnLatter(wordsOnScreen, wordSet);
25  
    newWords = onlyStringsShorterThan(100, newWords);
26  
    
27  
    if (nempty(newWords)) {
28  
      syncAddAll(wordSet, newWords);
29  
      print("Learned new words (now " + n2(wordSet) + "): " + shorten(joinWithComma(newWords), 200));
30  
      change();
31  
    }
32  
  }
33  
}

Author comment

Began life as a copy of #1016967

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: #1016970
Snippet name: Remember Words Seen In Any Swing Component
Eternal ID of this version: #1016970/16
Text MD5: 6bbd25c5d0221d81da7b9c56e773f1b6
Transpilation MD5: 6a4316f0eefdbbe16872dd9e69521a19
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-09 17:11:23
Source code size: 895 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 383 / 695
Version history: 15 change(s)
Referenced in: [show references]