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

13
LINES

< > BotCompany Repo | #1031122 // componentAtScreenLocationInWindow

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2919L/17K).

static Component componentAtScreenLocationInWindow(Window window, int x, int y) {
  if (window == null) null;
  ret swing(func -> Component {
    Point p = new(x, y);
    SwingUtilities.convertPointFromScreen(p, window);
    ret SwingUtilities.getDeepestComponentAt(window, p.x, p.y);
  });
}

static Component componentAtScreenLocationInWindow(Window window, MouseEvent e) {
  Point p = e.getLocationOnScreen();
  ret componentAtScreenLocationInWindow(window, p.x, p.y);
}

Author comment

Began life as a copy of #1019640

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031122
Snippet name: componentAtScreenLocationInWindow
Eternal ID of this version: #1031122/1
Text MD5: d78730bf1e42f1c8d555808c8c1b403f
Transpilation MD5: 8d98bcda3157563fd4c0dfcb13397618
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-07 15:51:04
Source code size: 487 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 75 / 117
Referenced in: [show references]