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

27
LINES

< > BotCompany Repo | #1007429 // Test componentAtMouse + wordAtMouse

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (4200L/30K).

1  
!7
2  
3  
p-subst {
4  
  swing {
5  
    JTable tbl = sexyTable();
6  
    dataToTable(tbl, litmap(aGlobalID(), aGlobalID(), aGlobalID(), aGlobalID()));
7  
    addToWindowBottomHalf(showText(lines(repF(10, f aGlobalID))), tbl);
8  
  }
9  
    
10  
  repeat with ms sleep 500 {
11  
    awt {
12  
      Component c = componentAtMouse();
13  
      if (c != null) {
14  
        Point d = mouseToComponent(c);
15  
        print("Mouse: " + d.x + ", " + d.y + ": " + c);
16  
        if (c instanceof JTextComponent) {
17  
          JTextComponent tc = cast c;
18  
          int idx = tc.viewToModel(d);
19  
          S text = tc.getText();
20  
          S word = wordAtMouse();
21  
          print("  " + quote(word) + " / " + quote(substring(text, idx-1, idx+1)));
22  
        }
23  
      } else
24  
        print("Mouse: " + c);
25  
    }
26  
  }
27  
}

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: #1007429
Snippet name: Test componentAtMouse + wordAtMouse
Eternal ID of this version: #1007429/17
Text MD5: c2fcc0f3ea60c0f0476c92653fb39e6d
Transpilation MD5: 7ab0b24c1f7d4292fd829754968601f6
Author: stefan
Category: javax / gui
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-23 14:48:49
Source code size: 775 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 458 / 957
Version history: 16 change(s)
Referenced in: [show references]