void () { final JPanel panel = new JPanel(new GridBagLayout()); final JTextField field1 = new JTextField(); field1.setPreferredSize(new Dimension(100,10)); final JTextField field2 = new JTextField(); field2.setPreferredSize(new Dimension(200,10)); GridBagConverter converter = new GridBagConverter(); converter.addComponent(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)); converter.addComponent(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)); applyConversionResults(panel, converter); 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 }