java swing的美化 如果将多选按钮改进成会变色的图标 最近在编一个小程序 用swing实现界面 想把那些多选项按钮改进一下全部改成图片的形式,按下图片 图片会外发光代表选上,再按一次外发光消失代表没选上想不出什么比较好的实现方式,大家有没有什么意见 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class MemoTypeListItemButton extends JButton implements ListCellRenderer<Object> { private ImageIcon icon = null; public MemoTypeListItemButton() { super(); initialize(); } /** * This method initializes this * */ private void initialize() { this.setSize(new Dimension(110, 31)); } @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String title = value.toString(); icon = new ImageIcon("src/image/"+(index+1)+".png"); setText(title); setIcon(icon); if (isSelected) { setBackground(new Color(18,165,199)); } else { setBackground(new Color(211,239,243));//这里设置不同的颜色 } return this; }}这个代码只是提示,希望帮到你 JMock高手请进!高分求解如果设定返回值的问题 java内部类作用域问题 求助…… java socket 监听程序总是隔几个小时就自动死掉。。在线等。。。 关于java版本的问题 反射invoke参数转型问题 applet装载图片的问题 请问JComboBox的控件怎么用 再问高手我的cloudscape的问题~急! 构造方法里面创建一个对象 重写和重载的区别?? 做下载工具,,网络编程中的问题。。
private ImageIcon icon = null; public MemoTypeListItemButton() {
super();
initialize();
} /**
* This method initializes this
*
*/
private void initialize() {
this.setSize(new Dimension(110, 31));
} @Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
String title = value.toString();
icon = new ImageIcon("src/image/"+(index+1)+".png");
setText(title);
setIcon(icon);
if (isSelected) {
setBackground(new Color(18,165,199));
} else {
setBackground(new Color(211,239,243));//这里设置不同的颜色
}
return this;
}
}
这个代码只是提示,希望帮到你