Q:

Set the length of border (jbutton) in Java

I have the button in Java (which includes text and icon), but with the default border, the border (the retangle outside the text and icon) is rather long, so how could I set the customed border (width, length) of jbutton. So far, i tried
button.setSize(x, y);

but it doesn't work.
Thanks.

A:

I might get the problem wrong, but you can set the border of a JButton like this:
Border border = new LineBorder(Color.WHITE, 12);
JButton button = new JButton("12 Pixel");

button.setBorder(border);

You might want to have a look at the documentation of LineBorder.

