0

Ok so I have this panel and 2 buttons. I want to add space between the buttons. Here's my code:

    smallpan.setPreferredSize(new Dimension(100,100));
    smallpan.setBackground(Color.white);
    panel2.setPreferredSize(new Dimension(100, 100));
    panel2.setBackground(Color.white);
    panel2.add(smallpan);
    panel2.add(x);
    panel2.add(y);
user7
  • 11
  • 1
  • 5

1 Answers1

0

You could use something like this - BorderLayout.setHgap(int hgap)for horizontal gap and BorderLayout.setVgap() for vertical gap between the elements. Or just specify it in the overloaded constructor - BorderLayout(int horizontalGap, int verticalGap).

For more information see this

Ramiz Wachtler
  • 5,623
  • 2
  • 28
  • 33