JPanel (final JComponent aComponent, final ActionListener aActionListener, int delta) { JPanel result = new JPanel(new GridBagLayout()); result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBInsets.emptyInsets(), 0, 0)); FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent); result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); browseButton.addActionListener(aActionListener); return result; }