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

14
LINES

< > BotCompany Repo | #1001308 // centerFrame

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

Libraryless. Click here for Pure Java version (5043L/28K).

static <A extends Component> A centerFrame(A c) {
  Window w = getWindow(c);
  if (w != null) swing {
    var r = preferredScreenBounds();
    w.setLocation(
      r.x+(r.w-w.getWidth())/2,
      r.y+(r.h-w.getHeight())/2);
  }
  ret c;
}

static <A extends Component> A centerFrame(int w, int h, A c) {
  ret centerFrame(setFrameSize(w, h, c));
}

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: #1001308
Snippet name: centerFrame
Eternal ID of this version: #1001308/8
Text MD5: 6211d216a717d55ed88ff4be136b4053
Transpilation MD5: 68500a1ee26263e256e72e5872a70968
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-21 20:38:03
Source code size: 362 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 740 / 1417
Version history: 7 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006701 - centerTopFrame - center, move to top of screen
#1009883 - centerWindow
#1015038 - centerFrameWithWidth
#1034098 - centerFrame_oldMethod
#1034124 - centerWindowWithin
#3000382 - Answer for ferdie (>> t = 1, f = 0)