void () { final JPanel panel = new JPanel(new GridBagLayout()); final JButton button = new JButton(); button.setPreferredSize(new Dimension(50, 10)); final JTextField field1 = new JTextField(); field1.setPreferredSize(new Dimension(50, 10)); final JTextField field2 = new JTextField(); GridBagConverter converter = new GridBagConverter(); converter.addComponent(button, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(field1, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(field2, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); applyConversionResults(panel, converter); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(100, preferredSize.width); panel.setSize(new Dimension(500, 100)); panel.doLayout(); assertEquals(500, field2.getWidth()); assertEquals(50, button.getWidth()); assertEquals(450, field1.getWidth()); }