1 package org.columba.core.gui.util; 19 20 import java.awt.BorderLayout ; 21 import java.awt.Color ; 22 import java.awt.Dimension ; 23 import java.awt.Font ; 24 import java.awt.GridBagConstraints ; 25 import java.awt.GridBagLayout ; 26 import java.awt.Insets ; 27 28 import javax.swing.BorderFactory ; 29 import javax.swing.ImageIcon ; 30 import javax.swing.JLabel ; 31 import javax.swing.JPanel ; 32 import javax.swing.SwingConstants ; 33 import javax.swing.UIManager ; 34 import javax.swing.border.CompoundBorder ; 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 44 45 public class DialogHeaderPanel extends JPanel { 46 47 public DialogHeaderPanel(String title, String description) { 48 this(title, description, null); 49 50 } 51 public DialogHeaderPanel(String title, String description, ImageIcon icon) { 52 53 setLayout( new BorderLayout ()); 54 55 setBackground(Color.white); 56 setPreferredSize(new Dimension (300, 60)); 57 setBorder(new CompoundBorder (new SingleSideEtchedBorder( 58 SwingConstants.BOTTOM), BorderFactory.createEmptyBorder(10, 10, 59 10, 10))); 60 61 JPanel leftPanel = new JPanel (); 62 leftPanel.setBackground(Color.white); 63 64 GridBagLayout layout = new GridBagLayout (); 65 leftPanel.setLayout(layout); 66 67 GridBagConstraints c = new GridBagConstraints (); 68 69 JLabel titleLabel = new JLabel (title); 70 71 Font 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 (0, 20, 0, 0); 83 84 JLabel descriptionLabel = new JLabel (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 iconLabel = new JLabel (icon); 94 95 add(iconLabel, BorderLayout.EAST); 96 97 } 98 } | Popular Tags |