ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.Component;
 
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
 
import com.vci.client.common.objects.RoleObject;
import com.vci.client.ui.image.BundleImage;
 
 
public class ListLabelCellRender extends JLabel implements ListCellRenderer {
 
    private static final long serialVersionUID = 1L;
    public ListLabelCellRender() {
        setOpaque(true);
    }
    public Component getListCellRendererComponent(
                        JList list,
                        Object value,
                        int index,
                        boolean isSelected,
                        boolean cellHasFocus){
        RoleObject entity = (RoleObject)value;
        if(entity != null){
            this.setIcon(new BundleImage().createImageIcon("role.png"));
            this.setText(entity.getName());
        }
 
        if(isSelected) {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        }
        else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }
        return this;
    }
}