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;
|
}
|
|
}
|