void () { final JPanel panel = new JPanel(new GridLayoutManager(1, 3, 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(110, 10)); 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, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0)); panel.doLayout(); assertEquals(190, panel.getPreferredSize().width); panel.setSize(new Dimension(500, panel.getHeight())); panel.doLayout(); assertEquals(80, button.getWidth()); assertEquals(420, field1.getWidth()); }