I want to make list of JButtons (with fixed dimensions, one beneath another) inside JScrollPane, using Swing. My idea was to make JPanel with GridBagLayout and add buttons in their suiting rows, and then create JScrollPane with that JPanel. That looks fine when number of buttons is large, but when the number of buttons is 2 or 3, I can't manage to align buttons one right below the other.
Also later I will add option to add new button (thus the + sign).

1. [Works fine with 10 buttons](https://i.stack.imgur.com/liGdc.png)
2. [I get this empty space between button 0 and button 1 when it's just 2 buttons (this is the problem)](https://i.stack.imgur.com/4EdK2.png)

3. The code (creates upper east panel)

```java
    private JPanel createLayerPanel() {
        JPanel layerPanel = new JPanel(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();

        // Label ------------------------------------------------
        JLabel layersLabel = new JLabel("Buttons");
        layersLabel.setHorizontalAlignment(SwingConstants.CENTER);
        layersLabel.setFont(DEFAULT_FONT);
        //layersLabel.setBorder(new LineBorder(Color.red, 3));
        layersLabel.setBackground(new Color(0x22222));
        layersLabel.setForeground(new Color(0xFFFFFF));

        layersLabel.setOpaque(true);
        c.gridx = c.gridy = 0;
        c.ipadx = 180;
        c.weightx = 1;
        c.fill = GridBagConstraints.BOTH;
        layerPanel.add(layersLabel, c);

        // Button ------------------------------------------------
        JButton newLayerBtn = new JButton("+");
        newLayerBtn.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 18));
        newLayerBtn.setBackground(new Color(0x222222));
        newLayerBtn.setForeground(Color.white);
        newLayerBtn.setFocusable(false);
        c.gridx = 1;
        c.gridy = 0;
        c.ipadx = 0;
        c.weightx = 0;
        layerPanel.add(newLayerBtn, c);

        // ScrollPane ------------------------------------------------
        //------------------------------------------------------------
        //------------------------------------------------------------

        JPanel layerListPanel = new JPanel(new GridBagLayout());
        layerListPanel.setBackground(Color.BLACK);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.weighty = 1;
        gbc.ipady = 40;
        gbc.gridx = 0;
        gbc.anchor = GridBagConstraints.NORTH;

        for (gbc.gridy = 0; gbc.gridy < 10; gbc.gridy++) {
            JButton btn = new JButton("Button " + gbc.gridy);
            layerListPanel.add(btn, gbc);
        }
        JScrollPane js = new JScrollPane(layerListPanel);
        js.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        // ...
        c.gridx = 0;
        c.gridy = 1;
        c.gridwidth = 2;
        c.weighty = 1;
        c.fill = GridBagConstraints.BOTH;

        layerPanel.add(js, c);
        return layerPanel;

    }

```