Reputation: 3544
I Want to change the JButton icon when user press/release the button.
A icon image when the JButton were selected
A icon image when the JButton were unselected and the JButton were release:
How can I do this?
Upvotes: 3
Views: 5142
Reputation: 618
JButton b = new JButton(Icon x); // Create button with normal icon
b.setIcon(Icon x);
b.setDisabledIcon(Icon x);
b.setPressedIcon(Icon x);
b.setSelectedIcon(Icon x);
b.setDisabledSelectedIcon(Icon x);
ref: http://www.leepoint.net/notes-java/GUI/components/20buttons/23buttonicons.html
Upvotes: 13