KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > util > DialogHeaderPanel


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.core.gui.util;
19
20 import java.awt.BorderLayout JavaDoc;
21 import java.awt.Color JavaDoc;
22 import java.awt.Dimension JavaDoc;
23 import java.awt.Font JavaDoc;
24 import java.awt.GridBagConstraints JavaDoc;
25 import java.awt.GridBagLayout JavaDoc;
26 import java.awt.Insets JavaDoc;
27
28 import javax.swing.BorderFactory JavaDoc;
29 import javax.swing.ImageIcon JavaDoc;
30 import javax.swing.JLabel JavaDoc;
31 import javax.swing.JPanel JavaDoc;
32 import javax.swing.SwingConstants JavaDoc;
33 import javax.swing.UIManager JavaDoc;
34 import javax.swing.border.CompoundBorder JavaDoc;
35
36 import org.columba.core.gui.base.SingleSideEtchedBorder;
37 import org.columba.core.resourceloader.IconKeys;
38 import org.columba.core.resourceloader.ImageLoader;
39
40 /**
41  * @author fdietz
42  *
43  */

44
45 public class DialogHeaderPanel extends JPanel JavaDoc {
46
47     public DialogHeaderPanel(String JavaDoc title, String JavaDoc description) {
48         this(title, description, null);
49         
50     }
51     public DialogHeaderPanel(String JavaDoc title, String JavaDoc description, ImageIcon JavaDoc icon) {
52
53         setLayout( new BorderLayout JavaDoc());
54         
55         setBackground(Color.white);
56         setPreferredSize(new Dimension JavaDoc(300, 60));
57         setBorder(new CompoundBorder JavaDoc(new SingleSideEtchedBorder(
58                 SwingConstants.BOTTOM), BorderFactory.createEmptyBorder(10, 10,
59                 10, 10)));
60
61         JPanel JavaDoc leftPanel = new JPanel JavaDoc();
62         leftPanel.setBackground(Color.white);
63
64         GridBagLayout JavaDoc layout = new GridBagLayout JavaDoc();
65         leftPanel.setLayout(layout);
66
67         GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
68
69         JLabel JavaDoc titleLabel = new JLabel JavaDoc(title);
70
71         //titleLabel.setAlignmentY(0);
72
Font JavaDoc font = UIManager.getFont("Label.font");
73         font = font.deriveFont(Font.BOLD);
74         titleLabel.setFont(font);
75         c.gridy = 0;
76         c.anchor = GridBagConstraints.NORTHWEST;
77         c.gridwidth = GridBagConstraints.REMAINDER;
78         layout.setConstraints(titleLabel, c);
79         leftPanel.add(titleLabel);
80
81         c.gridy = 1;
82         c.insets = new Insets JavaDoc(0, 20, 0, 0);
83
84         JLabel JavaDoc descriptionLabel = new JLabel JavaDoc(description);
85         layout.setConstraints(descriptionLabel, c);
86         leftPanel.add(descriptionLabel);
87
88         add(leftPanel, BorderLayout.WEST);
89
90         if (icon == null)
91             icon = ImageLoader.getIcon(IconKeys.PREFERENCES);
92
93         JLabel JavaDoc iconLabel = new JLabel JavaDoc(icon);
94
95         add(iconLabel, BorderLayout.EAST);
96
97     }
98 }
Popular Tags