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