I tried to use a custom image for a JButton, and it works well except for the fact that there is a white box around it. I am not sure how to fix this, and would like some help. (I create the button using new ImageButton("Quit", "src/button.png", 128, 64). The button is not resizable, and the image file is 256X128)
Button Class:
public class ImageButton extends JButton {
Image image;
ImageObserver imageObserver;
public ImageButton(String text, String filename, int width, int height) {
super(text, new ImageIcon(filename));
setSize(width, height);
setHorizontalTextPosition(JButton.CENTER);
setVerticalTextPosition(JButton.CENTER);
}
}
Picture using getInsets override: