I'm trying to create a icon in a button in JButton, the button should look like this
But when i add this in my code it looks like this
Here is the button portion of my code
private JButton backButton = new JButton();
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionBack();
}
});
backButton.setIcon(new ImageIcon(Hello.class.getResource("/239706184.png")));
backButton.setEnabled(false);
buttonPanel.add(backButton);
Your button is dark because you set eneable to false
remove this line:
backButton.setEnabled(false);
If you set backButton.setEnabled(false);
then it will be showing in dark state.
Try it set to true.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.