1 package org.qdwizard;
2
3
4 import java.awt.Dimension;
5 import java.awt.Font;
6 import java.awt.Graphics2D;
7 import java.awt.GridLayout;
8 import java.awt.Image;
9 import java.awt.RenderingHints;
10
11 import javax.swing.JPanel;
12
13 /***
14 *
15 * Screen Header
16 * <p>Contains a wizard title, a subtitle used to display the name of the current screen and an optional background image</p>
17 *
18 * @author Bertrand Florat
19 * @created 1 may 2006
20 */
21 class Header extends JPanel{
22
23 private static final long serialVersionUID = 1L;
24 JPanel jta;
25 Image backgroundImage;
26 String sTitleText;
27 String sSubtitleText;
28
29 /***
30 *
31 * @param sTextID I18N ID of header
32 */
33 public Header(){
34 setLayout(new GridLayout());
35 jta = new JPanel();
36 jta.setOpaque(true);
37 jta.setPreferredSize(new Dimension(0,70));
38 add(jta);
39 }
40
41 /***
42 * Set the header title text
43 * @param sText
44 */
45 public void setTitleText(String sText){
46 sTitleText = sText;
47 }
48
49 /***
50 * Set the header subtitle text
51 * @param sText
52 */
53 public void setSubtitleText(String sText){
54 sSubtitleText = sText;
55 }
56
57 /***
58 * Set the header Image
59 * @param img
60 */
61 public void setImage(Image img){
62 backgroundImage = img;
63 }
64
65
66 public void paint(java.awt.Graphics g) {
67 super.paint(g);
68 Graphics2D g2D = (Graphics2D)g;
69 java.awt.Rectangle rect = getBounds();
70 g2D.setColor(java.awt.Color.WHITE);
71 g2D.fillRect(rect.x,rect.y,rect.width,rect.height);
72
73 if (backgroundImage != null)
74 g2D.drawImage(backgroundImage, 0,0,rect.width,rect.height, this);
75
76 g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
77 g2D.setColor(java.awt.Color.BLACK);
78 g2D.setFont(new Font("Dialog",Font.BOLD,14));
79 g2D.drawString(sTitleText, 20,25);
80
81 g2D.setFont(new Font("Dialog",Font.PLAIN,13));
82 g2D.drawString(sSubtitleText, 20,50);
83
84 g2D.setColor(java.awt.Color.BLACK);
85 g2D.drawLine(rect.x,rect.height-1,rect.width,rect.height-1);
86 }
87 }