IAmBlake IAmBlake - 1 year ago 128
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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download