[英]How to change JButton Icon when selected?
I Want to change the JButton icon when user press/release the button. 我想在用户按下/释放按钮时更改JButton图标。
A icon image when the JButton were selected 选择JButton时的图标图像
A icon image when the JButton were unselected and the JButton were release: 取消选择JButton并释放JButton时的图标图像:
How can I do this? 我怎样才能做到这一点?
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 参考: http : //www.leepoint.net/notes-java/GUI/components/20buttons/23buttonicons.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.