1
2
3
4
5
6
7
8
9
10
11
12 package com.eviware.soapui.support;
13
14 import java.awt.BorderLayout;
15 import java.awt.Color;
16
17 import javax.swing.BorderFactory;
18 import javax.swing.ImageIcon;
19 import javax.swing.JLabel;
20 import javax.swing.JPanel;
21 import javax.swing.UIManager;
22
23 import com.eviware.soapui.support.swing.GradientPanel;
24
25 public class DescriptionPanel extends GradientPanel
26 {
27 private JLabel titleLabel;
28 private JLabel descriptionLabel;
29
30 public DescriptionPanel(String title, String description, ImageIcon icon)
31 {
32 super( new BorderLayout() );
33 setBackground( UIManager.getColor( "control" ) );
34 setForeground( Color.WHITE );
35 setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder( 0, 0,
36 1, 0, Color.DARK_GRAY ), BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ) );
37
38 descriptionLabel = new JLabel();
39 setDescription(description);
40
41 JPanel innerPanel = new JPanel( new BorderLayout() );
42 innerPanel.add( descriptionLabel, BorderLayout.CENTER );
43 innerPanel.setOpaque( false );
44
45 if( title != null )
46 {
47 descriptionLabel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 0, 0 ) );
48 titleLabel = new JLabel( "<html><div style=\"font-size: 9px\"><b>" + title
49 + "</b></div></html>" );
50 innerPanel.add( titleLabel, BorderLayout.NORTH );
51 }
52 add( innerPanel, BorderLayout.CENTER );
53
54 if( icon != null )
55 {
56 JLabel iconLabel = new JLabel( icon );
57 iconLabel.setBorder( BorderFactory.createEmptyBorder( 0, 10, 0, 0 ) );
58 add( iconLabel, BorderLayout.EAST );
59 }
60 }
61
62 public void setTitle(String title)
63 {
64 titleLabel.setText( "<html><div style=\"font-size: 9px\"><b>" + title
65 + "</b></div></html>" );
66 }
67
68 public void setDescription(String description)
69 {
70 descriptionLabel.setText( "<html><div style=\"font-size: 9px\">" + description + "</div></html>" );
71 }
72 }