void () { final JPanel panel = new JPanel(new GridBagLayout()); // label textfield(span 2) // textfield(span 2) final JTextField label = new JTextField(); label.setPreferredSize(new Dimension(10,30)); final JTextField field1 = new JTextField(); field1.setPreferredSize(new Dimension(100,30)); final JTextField field2 = new JTextField(); field2.setPreferredSize(new Dimension(100,30)); GridBagConverter converter = new GridBagConverter(); converter.addComponent(label, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(0,0), null, null)); converter.addComponent(field1, new GridConstraints(0,1,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(0,0), null, null)); converter.addComponent(field2, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(0,0), null, null)); applyConversionResults(panel, converter); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(110, preferredSize.width); assertEquals(60, preferredSize.height); }