Libraryless. Click here for Pure Java version (2745L/18K).
static <A extends Component> A maximizeFrame(A c) { JFrame f = swing(func -> JFrame { JFrame f = getFrame(c); if (f != null) f.setExtendedState(JFrame.MAXIMIZED_BOTH); ret f; }); // wait until frame is actually maximized so // we can add components based on correct size if (f != null && !isAWTThread()) { Dimension d = maximumWindowBounds().getSize(); long start = sysNow(); repeat with ms sleep 1 { if (f.getWidth() >= d.getWidth()-100 && f.getHeight() >= d.getHeight()-100) break; if (sysNow() >= start+100) { warn("maximizeFrame timeout"); break; } } } ret c; }
Began life as a copy of #1003513
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1003516 |
| Snippet name: | maximizeFrame - better in non-AWT thread (so it can wait for the maximization) |
| Eternal ID of this version: | #1003516/11 |
| Text MD5: | a4f46de977d99e59fc669d8a71bd2209 |
| Transpilation MD5: | 801216af603530ee3f705dcbb618604a |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-06-14 17:37:13 |
| Source code size: | 649 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1261 / 1488 |
| Version history: | 10 change(s) |
| Referenced in: | [show references] |