当用户按下/释放按钮时,我希望更改JButton图标。
一个JButton被选中时的图标:
JButton未被选中且未被按下时的图标:
我该如何实现这个功能?
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);
参考资料: http://www.leepoint.net/notes-java/GUI/components/20buttons/23buttonicons.html