void () { final JPanel panel = new JPanel(new GridBagLayout()); final JTextField field1 = new JTextField(); field1.setMinimumSize(new Dimension(5,20)); field1.setPreferredSize(new Dimension(10,20)); final JTextField field2 = new JTextField(); field2.setMinimumSize(new Dimension(25,20)); field2.setPreferredSize(new Dimension(50,20)); final JTextField field3 = new JTextField(); field3.setMinimumSize(new Dimension(70,20)); field3.setPreferredSize(new Dimension(100,20)); GridBagConverter converter = new GridBagConverter(new Insets(0, 0, 0, 0), 7, 0, true, false); converter.addComponent(field1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(field2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(field3, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); applyConversionResults(panel, converter); final Dimension minimumSize = panel.getMinimumSize(); assertEquals(70 + 7 + 70 + 7 + 70, minimumSize.width); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(100 + 7 + 100 + 7 + 100, preferredSize.width); // panel.setSize(panel.getPreferredSize()); panel.doLayout(); assertEquals(100, field1.getWidth()); assertEquals(100, field2.getWidth()); assertEquals(100, field3.getWidth()); // panel.setSize(new Dimension(1000, 1000)); panel.doLayout(); assertEquals(329, field1.getWidth(), 1.0); assertEquals(329, field2.getWidth(), 1.0); assertEquals(328, field3.getWidth(), 1.0); }