void () { final JPanel panel = new JPanel(new GridBagLayout()); final JTextField field1 = new JTextField(); field1.setMinimumSize(new Dimension(110,10)); field1.setPreferredSize(new Dimension(120,10)); final JTextField field2 = new JTextField(); field2.setMinimumSize(new Dimension(215,10)); field2.setPreferredSize(new Dimension(225,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, 0)); 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, 0)); applyConversionResults(panel, converter); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(345, preferredSize.width); final Dimension minSize = panel.getMinimumSize(); assertEquals(325, minSize.width); panel.setSize(preferredSize.width, preferredSize.height); panel.doLayout(); assertEquals(120, field1.getWidth()); assertEquals(225, field2.getWidth()); panel.setSize(400, panel.getWidth()); panel.invalidate(); // to invalidate layout panel.doLayout(); }