001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.core.gui.util;
019:
020: import java.awt.BorderLayout;
021: import java.awt.Color;
022: import java.awt.Dimension;
023: import java.awt.Font;
024: import java.awt.GridBagConstraints;
025: import java.awt.GridBagLayout;
026: import java.awt.Insets;
027:
028: import javax.swing.BorderFactory;
029: import javax.swing.ImageIcon;
030: import javax.swing.JLabel;
031: import javax.swing.JPanel;
032: import javax.swing.SwingConstants;
033: import javax.swing.UIManager;
034: import javax.swing.border.CompoundBorder;
035:
036: import org.columba.core.gui.base.SingleSideEtchedBorder;
037: import org.columba.core.resourceloader.IconKeys;
038: import org.columba.core.resourceloader.ImageLoader;
039:
040: /**
041: * @author fdietz
042: *
043: */
044:
045: public class DialogHeaderPanel extends JPanel {
046:
047: public DialogHeaderPanel(String title, String description) {
048: this (title, description, null);
049:
050: }
051:
052: public DialogHeaderPanel(String title, String description,
053: ImageIcon icon) {
054:
055: setLayout(new BorderLayout());
056:
057: setBackground(Color.white);
058: setPreferredSize(new Dimension(300, 60));
059: setBorder(new CompoundBorder(new SingleSideEtchedBorder(
060: SwingConstants.BOTTOM), BorderFactory
061: .createEmptyBorder(10, 10, 10, 10)));
062:
063: JPanel leftPanel = new JPanel();
064: leftPanel.setBackground(Color.white);
065:
066: GridBagLayout layout = new GridBagLayout();
067: leftPanel.setLayout(layout);
068:
069: GridBagConstraints c = new GridBagConstraints();
070:
071: JLabel titleLabel = new JLabel(title);
072:
073: //titleLabel.setAlignmentY(0);
074: Font font = UIManager.getFont("Label.font");
075: font = font.deriveFont(Font.BOLD);
076: titleLabel.setFont(font);
077: c.gridy = 0;
078: c.anchor = GridBagConstraints.NORTHWEST;
079: c.gridwidth = GridBagConstraints.REMAINDER;
080: layout.setConstraints(titleLabel, c);
081: leftPanel.add(titleLabel);
082:
083: c.gridy = 1;
084: c.insets = new Insets(0, 20, 0, 0);
085:
086: JLabel descriptionLabel = new JLabel(description);
087: layout.setConstraints(descriptionLabel, c);
088: leftPanel.add(descriptionLabel);
089:
090: add(leftPanel, BorderLayout.WEST);
091:
092: if (icon == null)
093: icon = ImageLoader.getIcon(IconKeys.PREFERENCES);
094:
095: JLabel iconLabel = new JLabel(icon);
096:
097: add(iconLabel, BorderLayout.EAST);
098:
099: }
100: }
|