package com.vci.client.framework.rightConfig.operate;
|
|
import java.awt.Component;
|
|
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.JList;
|
|
import com.vci.client.common.objects.RoleObject;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
|
|
|
public class ObjectListCellRenderer extends DefaultListCellRenderer {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
public ObjectListCellRenderer()
|
{
|
|
}
|
|
@Override
|
public Component getListCellRendererComponent(JList list,
|
Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
|
String icon = "";
|
if (value instanceof RoleObject){
|
icon = "role.png";
|
}else {
|
icon = "object.png";
|
}
|
|
if (icon.isEmpty())
|
setIcon(null);
|
else
|
setIcon(VCISwingUtil.createImageIcon(icon));
|
|
setText((value == null) ? "" : value.toString());
|
|
// if (isSelected) {
|
// setBackground(list.getSelectionBackground());
|
// setForeground(list.getSelectionForeground());
|
// } else {
|
// // 设置选取与取消选取的前景与背景颜色.
|
// setBackground(list.getBackground());
|
// setForeground(list.getForeground());
|
// }
|
|
return this;
|
}
|
}
|