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

19
LINES

< > BotCompany Repo | #1015371 // boundsInParent

JavaX fragment (include)

1  
static Rect boundsInParent(Component c, Class<? extends Component> parentType) {
2  
  ret boundsInParent(c, parentOfType(c, parentType));
3  
}
4  
5  
static Rect boundsInParent(Component _c, Component parent) {
6  
  if (_c == null) null;
7  
  
8  
  ret swing(func -> Rect {
9  
    if (_c == parent) ret Rect(0, 0, _c.getWidth(), _c.getHeight());
10  
    Rect r = toRect(_c.getBounds());
11  
    Component c = _c;
12  
    while true {
13  
      c = c.getParent();
14  
      if (c == null) null;
15  
      if (c == parent) ret r;
16  
      r = translateRect(r, c.getX(), c.getY());
17  
    }
18  
  });
19  
}

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: #1015371
Snippet name: boundsInParent
Eternal ID of this version: #1015371/13
Text MD5: 4ce3fb36296e2bdfe84321255fb80fe8
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-13 23:35:23
Source code size: 561 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 322 / 367
Version history: 12 change(s)
Referenced in: [show references]