ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
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
42
43
44
45
46
package com.vci.client.ui.swing;
 
import javax.swing.ImageIcon;
import javax.swing.JLabel;
 
import com.vci.client.ui.image.BundleImage;
 
/**
 * 
 * @author Administrator
 *
 */
public class CheckBoxLabel extends JLabel{
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    public static class State { private State() { } }
    public static final State NOT_SELECTED = new State();
    public static final State SELECTED = new State();
    public static final State DONT_CARE = new State();
    private static final ImageIcon selectIcon = new BundleImage().createImageIcon("checkBoxSelected.gif");
    private static final ImageIcon unSelectIcon = new BundleImage().createImageIcon("checkBoxUnSelected.gif");
    private static final ImageIcon partialSelectIcon = new BundleImage().createImageIcon("checkBoxPartialSelected.gif");
    
    public CheckBoxLabel() {
        super();
        try {
            this.setIcon(CheckBoxLabel.unSelectIcon);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void setState(State state) {
        if (state == NOT_SELECTED) { 
            this.setIcon(unSelectIcon);
        } else if (state == SELECTED) {
            this.setIcon(selectIcon);
        } else { // either "null" or DONT_CARE
            this.setIcon(partialSelectIcon);
        }
    }
}