Component (final String title, int gridx, int gridy) { GridBagConstraints buttonConstraints = new GridBagConstraints(); buttonConstraints.gridx = gridx; buttonConstraints.gridy = gridy; buttonConstraints.fill = GridBagConstraints.HORIZONTAL; buttonConstraints.anchor = GridBagConstraints.NORTHWEST; buttonConstraints.ipadx = 20; buttonConstraints.ipady = 20; JButton button = new JButton(title); add(button, buttonConstraints); return button; }