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

11
LINES

< > BotCompany Repo | #1003584 // boundsOnScreen - get actual bounds of JComponent on screen (honoring a possible scroll pane)

JavaX fragment (include)

static Rectangle boundsOnScreen(Component c) {
  if (c == null) null;
  if (c.getParent() instanceof JViewport
    && c.getParent().getParent() instanceof JScrollPane)
    c = c.getParent().getParent();
  try { 
    ret new Rectangle(c.getLocationOnScreen(), c.getSize());
  } catch (IllegalComponentStateException e) {
    null;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003584
Snippet name: boundsOnScreen - get actual bounds of JComponent on screen (honoring a possible scroll pane)
Eternal ID of this version: #1003584/2
Text MD5: c30748f3d60a78961f317f3698477c6b
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-10 16:05:16
Source code size: 345 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 598 / 724
Version history: 1 change(s)
Referenced in: [show references]