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

16
LINES

< > BotCompany Repo | #1009883 // centerWindow

JavaX fragment (include)

1  
static Window centerWindow(Component c) {
2  
  Window w = getWindow(c);
3  
  if (w != null)
4  
    w.setLocationRelativeTo(null); // magic trick
5  
  ret w;
6  
}
7  
8  
static Window centerWindow(Component c, int width, int height) {
9  
  setWindowSize(c, width, height);
10  
  ret centerWindow(c);
11  
}
12  
13  
static JWindow centerWindow(JWindow w) {
14  
  centerWindow(getRootPane(w));
15  
  ret w;
16  
}

Author comment

Began life as a copy of #1001308

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: #1009883
Snippet name: centerWindow
Eternal ID of this version: #1009883/4
Text MD5: e0ac975aa2577cad710db7fb063a7fd2
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-02 23:26:17
Source code size: 372 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 508 / 554
Version history: 3 change(s)
Referenced in: [show references]