views:

159

answers:

2

Is it possible to make a JButton take exactly the size of its text? Since by default, a JButton will have a small amount of padding (both horizontal and vertical) around its text. I would like to remove that padding.

A picture to explain myself better

thx

+1  A: 

JButton has a border by default, you can remove it:

button.setBorder(null);
Peter Lang
Thanks, and sorry for asking such a simple question.
Spi1988
+1  A: 

IMO you just have to set buttons margins to 0. See JButton.setMargin

eugener