0

Hi just a quick question. I want to remove the ugly grey border the JButtons create.

http://gyazo.com/e9f57308190e1b6d49ac7b300fce2a4b

    setBackground(null);
    .setOpaque(false);
    .setBorderPainted(false);

none of these work, im sure it's a one liner, any help appricated.

EightSquared
  • 37
  • 2
  • 13

2 Answers2

2

As far as I know you can use the setBorder() method for this. Something along these lines should work:

Border noBorder = new LineBorder(Color.WHITE, 0);
JButton borderlessButton = new JButton("No Border");
borderlessButton.setBorder(noBorder);
mvreijn
  • 2,807
  • 28
  • 40
2

I think you're looking for a combination of JButton#setContentAreaFilled and JButton#setBorderPainted

You might also like to use JButton#setFocusPainted as well

For example, example and example

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366