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

19
LINES

< > BotCompany Repo | #1010287 // fixInternalFrame - move into view if outside (maybe slightly wrongish)

JavaX fragment (include)

1  
static int fixInternalFrame_borderTopLeft = 0;
2  
static int fixInternalFrame_borderBottomRight = 40; // for title bar
3  
4  
static JInternalFrame fixInternalFrame(final JInternalFrame f) {
5  
  ret swing(func -> JInternalFrame {
6  
    Container c = f.getParent();
7  
    if (c == null) ret f;
8  
    Rect r = toRect(f.getBounds());
9  
    int a = fixInternalFrame_borderTopLeft, b = fixInternalFrame_borderBottomRight;
10  
    Rect outer = new Rect(a, a, c.getWidth()-b, c.getHeight()-b);
11  
    if (!rectContains(outer, r))
12  
      f.setLocation(
13  
        max(a, min(r.x, outer.x2())),
14  
        max(a, min(r.y, outer.y2())));
15  
    if (r.w > c.getWidth() || r.h > c.getHeight())
16  
      f.setSize(c.getWidth()-a, c.getHeight()-a);
17  
    ret f;
18  
  });
19  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010287
Snippet name: fixInternalFrame - move into view if outside (maybe slightly wrongish)
Eternal ID of this version: #1010287/11
Text MD5: 8dc352af0d6a130798fecb50750538ce
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-29 19:39:43
Source code size: 734 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 522 / 577
Version history: 10 change(s)
Referenced in: [show references]