void () { final JPanel panel = new JPanel(new GridBagLayout()); final JButton btn1 = new JButton(); btn1.setPreferredSize(new Dimension(100,20)); final JButton btn2 = new JButton(); btn2.setPreferredSize(new Dimension(100,20)); final JButton btn3 = new JButton(); btn3.setPreferredSize(new Dimension(100,20)); final JButton btn4 = new JButton(); btn4.setPreferredSize(new Dimension(100,20)); GridBagConverter converter = new GridBagConverter(new Insets(0, 0, 0, 0), 7, 0, false, false); converter.addComponent(btn1, 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(btn2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(btn3, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); converter.addComponent(btn4, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); applyConversionResults(panel, converter); final Dimension preferredSize = panel.getPreferredSize(); assertEquals(314, preferredSize.width); panel.setSize(panel.getPreferredSize()); panel.doLayout(); }