IAmBlake IAmBlake - 9 months ago 60
Java Question

How to add a icon in JButton

I'm trying to create a icon in a button in JButton, the button should look like this

enter image description here

But when i add this in my code it looks like this

enter image description here

Here is the button portion of my code

private JButton backButton = new JButton();
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
backButton.setIcon(new ImageIcon(Hello.class.getResource("/239706184.png")));

Answer Source

Your button is dark because you set eneable to false

remove this line: