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
package com.vci.client.ui.swing;
 
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.LinearGradientPaint;
import java.awt.Point;
 
import com.vci.client.ui.swing.components.VCIJLabel;
 
 
public class VCITitleBar extends VCIJLabel {
    /**
     * 
     */
    private static final long serialVersionUID = 9053003685744738465L;
    private String text = "";
    private String iconUrl = "";
 
    private Color color1 = VCISwingUtil.TBC1;
    private Color color2 = VCISwingUtil.TBC2;
    private Color color3 = VCISwingUtil.TBC3;
    private Color color4 = VCISwingUtil.TBC4;
    private Color borderColor = VCISwingUtil.FRAMECOLOR;
 
    public VCITitleBar(String text, String iconUrl) {
        this.text = text;
        this.iconUrl = iconUrl;
    }
 
    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
 
        Point start = new Point(0, 0);
        Point end = new Point(0, 25);
        float[] dist = { 0.0f, 0.45f, 0.5f, 1.0f };
        Color[] colors = { color1, color2, color3, color4 };
        LinearGradientPaint lgp = new LinearGradientPaint(start, end, dist,
                colors);
 
        g2.setPaint(lgp);
        g2.fillRect(0, 0, getWidth(), getHeight());
        g2.setColor(borderColor);
        g2.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        if (getIconUrl() != null) {
            Image img = VCISwingUtil.createImageIcon(getIconUrl()).getImage();
            if (img != null) {
                g2.drawImage(img, 8, 4, 16, 16, null);
            }
        }
        g2.setColor(VCISwingUtil.TEXTCOLOR);
        g2.setFont(VCISwingUtil.Font12B);
        g2.drawString(getText(), 30, 17);
        g2.dispose();
    }
 
    public String getText() {
        return text;
    }
 
    public void setText(String text) {
        this.text = text;
    }
 
    public String getIconUrl() {
        return iconUrl;
    }
 
    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }
 
}