Libraryless. Click here for Pure Java version (5043L/28K).
1 | static <A extends Component> A centerFrame(A c) {
|
2 | Window w = getWindow(c); |
3 | if (w != null) swing {
|
4 | var r = preferredScreenBounds(); |
5 | w.setLocation( |
6 | r.x+(r.w-w.getWidth())/2, |
7 | r.y+(r.h-w.getHeight())/2); |
8 | } |
9 | ret c; |
10 | } |
11 | |
12 | static <A extends Component> A centerFrame(int w, int h, A c) {
|
13 | ret centerFrame(setFrameSize(w, h, c)); |
14 | } |
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: | 1019 / 1741 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |