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
|
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.customcontrols;
import java.awt.*;
import javax.swing.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>TitlePanel</tt> is a decorated panel, that could be used for a header
* or a title area. This panel is used for example in the
* <tt>ConfigurationFrame</tt>.
*
* @author Yana Stamcheva
*/
public class TitlePanel
extends TransparentPanel
{
private static final long serialVersionUID = 1L;
private final JLabel titleLabel = new JLabel();
private final Color gradientStartColor = new Color(255, 255, 255, 200);
private final Color gradientEndColor = new Color(255, 255, 255, 50);
/**
* Creates an instance of <tt>TitlePanel</tt>.
*/
public TitlePanel()
{
this(null);
}
/**
* Creates an instance of <tt>TitlePanel</tt> by specifying the title
* String.
*
* @param title A String title.
*/
public TitlePanel(String title)
{
super(new FlowLayout(FlowLayout.CENTER));
Font font = getFont();
titleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize() + 2));
if (title != null)
setTitleText(title);
else
setPreferredSize(new Dimension(0, 30));
}
/**
* Overrides the <code>paintComponent</code> method of <tt>JPanel</tt> to
* paint a gradient background of this panel.
*/
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
AntialiasingManager.activateAntialiasing(g2);
int width = getWidth();
int height = getHeight();
GradientPaint p =
new GradientPaint(width / 2,
0,
gradientStartColor,
width / 2,
height,
gradientEndColor);
g2.setPaint(p);
g2.fillRoundRect(0, 0, width, height, 10, 10);
super.paintComponent(g2);
}
/**
* Sets the title String.
*
* @param title The title String.
*/
public void setTitleText(String title)
{
this.removeAll();
this.titleLabel.setText(title);
this.add(titleLabel);
}
}
|