1 package com.opensymphony.workflow.designer.swing; 2 3 import java.awt.*; 4 import javax.swing.*; 5 import javax.swing.border.CompoundBorder ; 6 import javax.swing.border.EtchedBorder ; 7 8 import com.opensymphony.workflow.designer.UIFactory; 9 10 public class BannerPanel extends JPanel 11 { 12 private JLabel titleLabel; 13 private JTextArea subtitleLabel; 14 private JLabel iconLabel; 15 16 public BannerPanel() 17 { 18 setBorder(new CompoundBorder (new EtchedBorder (), BorderFactory.createEmptyBorder(3, 3, 3, 3))); 19 20 setOpaque(true); 21 setBackground(UIManager.getColor("Table.background")); 22 23 titleLabel = new JLabel(); 24 titleLabel.setOpaque(false); 25 26 subtitleLabel = new JTextArea("<html>"); 27 subtitleLabel.setFont(titleLabel.getFont()); 28 titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); 29 30 subtitleLabel.setWrapStyleWord(true); 31 subtitleLabel.setEditable(false); 32 subtitleLabel.setOpaque(false); 33 subtitleLabel.setLineWrap(true); 34 35 UIFactory.htmlize(subtitleLabel); 36 37 iconLabel = new JLabel(); 38 iconLabel.setPreferredSize(new Dimension(50, 50)); 39 40 setLayout(new BorderLayout()); 41 42 JPanel nestedPane = new JPanel(new BorderLayout()); 43 nestedPane.setOpaque(false); 44 nestedPane.add(titleLabel, BorderLayout.NORTH); 45 nestedPane.add(subtitleLabel, BorderLayout.CENTER); 46 add(nestedPane, BorderLayout.CENTER); 47 add(iconLabel, BorderLayout.EAST); 48 } 49 50 public void setTitleColor(Color color) 51 { 52 titleLabel.setForeground(color); 53 } 54 55 public void setSubtitleColor(Color color) 56 { 57 subtitleLabel.setForeground(color); 58 } 59 60 public void setTitle(String title) 61 { 62 titleLabel.setText(title); 63 } 64 65 public void setSubtitle(String subtitle) 66 { 67 subtitleLabel.setText(subtitle); 68 } 69 70 public void setIcon(Icon icon) 71 { 72 iconLabel.setIcon(icon); 73 } 74 } 75 | Popular Tags |