问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/12468203/how-to-change-jbutton-icon-when-selected