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

34
LINES

< > BotCompany Repo | #1001738 // Get active Swing component (search all VMs)

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

Libraryless. Click here for Pure Java version (1552L/11K/37K).

!747
!pcall

m {
  p {
    new TreeMap results;
    for (DialogIO vm : talkToAllOtherVMs()) {
      pcall {
        int vmPort = vm.getPort();
        Map<Number, S> bots = (Map) safeUnstructure(vm.ask("list bots"));
        print("VM " + vmPort + " bots: " + structure(bots));
        if (!containsBot(bots, "Get Active Swing Component Bot")) {
          print("Injecting bot.");
          injectTo(vmPort, "#1001734");
        }
        S result = vm.ask("please forward to bot *: *", "Get Active Swing Component Bot", "get active component");
        results.put(vmPort, result);
      }
      vm.close();
    }
    
    // include myself
    results.put(myVMPort(), weakref(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()));
    
    print("Results: " + structure(results));
  }
  
  static boolean containsBot(Map<Number, S> bots, S botName) {
    for (S bot : bots.values())
      if (startsWithIgnoreCase(bot, botName))
        ret true;
    ret false;
  }
}

Author comment

Began life as a copy of #1001720

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: #1001738
Snippet name: Get active Swing component (search all VMs)
Eternal ID of this version: #1001738/1
Text MD5: bc1c91555cfb4732122489427fb51bf5
Transpilation MD5: cac8e5c76adb7ad874825f52c8420a2a
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-11-11 01:49:35
Source code size: 1020 bytes / 34 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 616 / 681
Referenced in: [show references]