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

19
LINES

< > BotCompany Repo | #1014840 // moveWindowIntoScreen - for restoring windows with coordinates possibly from another screen

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

Libraryless. Click here for Pure Java version (2333L/15K).

1  
static Window moveWindowIntoScreen(final Window w) {
2  
  if (w != null) swing {
3  
    Rectangle s = usableWindowArea();
4  
    Rectangle r1 = w.getBounds();
5  
    Rectangle r = new Rectangle(r1);
6  
    
7  
    // adjust size
8  
    r.width = min(r.width, s.width);
9  
    r.height = min(r.height, s.height);
10  
    
11  
    // adjust position
12  
    r.x = min(x2(s)-r.width, max(r.x, s.x));
13  
    r.y = min(y2(s)-r.height, max(r.y, s.y));
14  
    
15  
    if (neq(r, r1))
16  
      w.setBounds(r);
17  
  }
18  
  ret w;
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: #1014840
Snippet name: moveWindowIntoScreen - for restoring windows with coordinates possibly from another screen
Eternal ID of this version: #1014840/5
Text MD5: 4f66a09f98f81a3410152fc9ba02dac8
Transpilation MD5: 58e78eba2a65e747760656950da4c237
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-04 15:10:26
Source code size: 486 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 370 / 465
Version history: 4 change(s)
Referenced in: [show references]