void () { final GridLayoutManager layoutManager = new GridLayoutManager(1,3); // min cell size should layoutManager.setHGap(0); layoutManager.setVGap(0); final JPanel panel = new JPanel(layoutManager); final JTextField field1 = new JTextField(); field1.setPreferredSize(new Dimension(100,10)); final JTextField field2 = new JTextField(); field2.setPreferredSize(new Dimension(200,10)); panel.add(field1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); panel.add(field2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(300 + 20, preferredSize.width); panel.setSize(preferredSize.width, preferredSize.height); panel.doLayout(); assertEquals(100, field1.getWidth()); assertEquals(200, field2.getWidth()); panel.setSize(270, preferredSize.height); panel.doLayout(); // should not fail }