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).

!7

sclass RememberAllWords > DynPrintLog {
  new LinkedHashSet<S> wordSet;
  int interval = 10000;
  
  void start {
    print("Got " + n2(l(wordSet), "word"));
    doEvery(interval, r doIt);
    if (syncEmpty(wordSet)) doIt();
  }
  
  void doIt {
    temp enter();
    please include function getText.

    new Set<S> wordsOnScreen;
    
    for (Component c : allComponentsInWindows()) {
      S text = (S) callOpt(mc(), 'getText, c); // Reflection abuse!
      addAll(wordsOnScreen, words2_notNextToNumbers(text));
    }
    
    Collection<S> newWords = setMinusSet_syncOnLatter(wordsOnScreen, wordSet);
    newWords = onlyStringsShorterThan(100, newWords);
    
    if (nempty(newWords)) {
      syncAddAll(wordSet, newWords);
      print("Learned new words (now " + n2(wordSet) + "): " + shorten(joinWithComma(newWords), 200));
      change();
    }
  }
}

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: 447 / 782
Version history: 15 change(s)
Referenced in: [show references]