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

19
LINES

< > BotCompany Repo | #1003296 // packFrame - improved version of JFrame.pack() (with minimum & maximum size)

JavaX fragment (include)

sint packFrame_minw = 150, packFrame_minh = 50;

static <A extends Component> A packFrame(final A c) {
  swing {
    Window w = getWindow(c);
    if (w != null) {
      w.pack();
      int maxW = getScreenWidth()-50, maxH = getScreenHeight()-50;
      w.setSize(
        min(maxW, max(w.getWidth(), packFrame_minw)),
        min(maxH, max(w.getHeight(), packFrame_minh)));
    }
  }
  ret c;
}

static JFrame packFrame(ButtonGroup g) {
  ret packFrame(getFrame(g));
}

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: #1003296
Snippet name: packFrame - improved version of JFrame.pack() (with minimum & maximum size)
Eternal ID of this version: #1003296/8
Text MD5: 09dd673669d4ec66186c3756ebbf72de
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-08 16:10:45
Source code size: 485 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 627 / 623
Version history: 7 change(s)
Referenced in: [show references]