-2

I am making an application in Java Swing and I have to use buttons there.

I have a button and I have set background image of JButton using ImageIcon. I have made this image using Photoshop When I click on the button then its default color is shown. I am also setting background color to white but this is not solving my problem.

How to remove default color of button?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Manjeet Rani
  • 31
  • 1
  • 7

1 Answers1

2

Make your image as a button :

BufferedImage buttonIcon = ImageIO.read(new File("MyImage"));
button = new JButton(new ImageIcon(buttonIcon));

and set your button like so :

button.setBorderPainted(false);
button.setFocusPainted(false);
button.setContentAreaFilled(false);
Mey Lam
  • 75
  • 7