set image to button java code example
Example 1: add image on JButton
buttonB.setIcon(new ImageIcon(this.getClass().getResource("imagename")));
Example 2: java button with jpg image
JButton button; // precondition: not null
ImageIcon icon = new ImageIcon(FirstWindow.class.getResource("/Background.jpeg"));
button.setIcon(icon);
button.setDisabledIcon(icon); // or a grayed-out version