void () { final JPanel panel = new JPanel(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), 0, 0)); final JButton button = new JButton(); setDefaults(button); button.setPreferredSize(new Dimension(80, 10)); final JTextField field1 = new JTextField(); setDefaults(field1); field1.setPreferredSize(new Dimension(80, 10)); final JTextField field2 = new JTextField(); setDefaults(field2); panel.add(button, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); panel.add(field1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); panel.add(field2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); panel.doLayout(); assertEquals(160, panel.getPreferredSize().width); panel.setSize(new Dimension(500, panel.getHeight())); panel.doLayout(); assertEquals(500, field2.getWidth()); assertEquals(250, button.getWidth()); assertEquals(250, field1.getWidth()); }