Set border length (jbutton) in Java

I have a button in Java (which includes text and an icon), but with a default border, the border (a border outside the text and icon) is quite long, since I can set a custom jbutton border (width, length). So far i tried

button.setSize(x, y); 

but that will not work.

Thanks.

+4
source share
2 answers

I may be wrong, but you can set the JButton border as follows:

 Border border = new LineBorder(Color.WHITE, 12); JButton button = new JButton("12 Pixel"); button.setBorder(border); 

Perhaps you should take a look at the LineBorder documentation .

+3
source
  setLayout(null); setPreferredSize(new Dimension(950, 550)); 

which worked for me, just resize to your liking ... goodluck hopes this works! just noticed the date. sorry for the grave maybe this will help someone else though lol

0
source

Source: https://habr.com/ru/post/1397811/


All Articles