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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.vci.client.ui.swing.components;
 
import java.awt.Color;
import java.awt.Graphics;
 
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JRadioButton;
 
import com.vci.client.ui.swing.VCISwingUtil;
 
/**
 * 
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author xchao
 * @time 2012-5-10
 * @version 1.0
 */
public class VCIJRadioButton extends JRadioButton {
 
    /**
     * 
     */
    private static final long serialVersionUID = -2910701065921338454L;
 
    public VCIJRadioButton() {
        this(null, null);
    }
 
    public VCIJRadioButton(Icon icon) {
        this(null, null);
    }
 
    public VCIJRadioButton(Action a) {
        this();
        if(a != null){
            setAction(a);
        }
    }
 
    public VCIJRadioButton(String text) {
        this(text, null, false);
    }
 
    public VCIJRadioButton(Icon icon, boolean selected) {
        this(null, icon, selected);
    }
 
    public VCIJRadioButton(String text, boolean selected) {
        this(text, null, selected);
    }
 
    public VCIJRadioButton(String text, Icon icon) {
        this(text, icon, false);
    }
 
    public VCIJRadioButton(String text, Icon icon, boolean selected) {
        super(text, icon, selected);
        customConstructor();
    }
    
 
 
    private void customConstructor(){
        setFont(VCISwingUtil.FONT_DEFAULT);
    }
    @Override
    public void paint(Graphics g){
        super.paint(g);
        if(isRequired()) {
            drawRequiredFlag(g);
        }
    }
 
    private void drawRequiredFlag(Graphics g){
        int x = getWidth() - 9;
        int y = 1;
        g.setColor(Color.RED);
        g.fillArc(x, y, 7, 7, 0, 360);        
//        int x = getWidth() - 10;
//        int y = 10;
//        g.setColor(Color.RED);
//        g.drawString("*", x, y);
    }
    
    private boolean required = false;
    
    public boolean isRequired() {
        return required;
    }
 
    public void setRequired(boolean required) {
        this.required = required;
    }
    
    private Object obj =  null;
    public Object getObj() {
        return obj;
    }
    public void setObj(Object obj) {
        this.obj = obj;
    }
}