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

20
LINES

< > TinyBrain | #1006237 - frameInnerSize - set content pane size of a frame

JavaX fragment (include)

static JFrame frameInnerSize(final Component c, final double w, final double h) {
  final JFrame frame = getFrame(c);
  if (frame != null) swing {
    Container cp = frame.getContentPane();
    Dimension oldSize = cp.getPreferredSize();
    cp.setPreferredSize(new Dimension(iround(w), iround(h)));
    frame.pack();
    cp.setPreferredSize(oldSize);
  }
  ret frame;
}

static void frameInnerSize(JFrame frame, Dimension d) {
  frameInnerSize(frame, d.width, d.height);
}

static JFrame frameInnerSize(Pt p, JFrame frame) {
  frameInnerSize(frame, p.x, p.y);
  ret frame;
}

download  show line numbers  debug dex   

Travelled to 3 computer(s): cfunsshuasjs, sawdedvomwva, tvejysmllsmz

No comments. add comment

Snippet ID: #1006237
Snippet name: frameInnerSize - set content pane size of a frame
Eternal ID of this version: #1006237/8
Text MD5: e32356796b4b138694f23e1a9295f14a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-20 13:10:32
Source code size: 593 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 87 / 61
Version history: 7 change(s)
Referenced in: [show]