void (Container parent) { Dimension size = parent.getSize(); Insets i = parent.getInsets(); Dimension pref = layoutPanel.getPreferredSize(); layoutPanel.setBounds(i.left, i.top, size.width - i.left - i.right, pref.height); }