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, 1, 0, Color.DARK_GRAY ),
36 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 + "</b></div></html>" );
49 innerPanel.add( titleLabel, BorderLayout.NORTH );
50 }
51 add( innerPanel, BorderLayout.CENTER );
52
53 if( icon != null )
54 {
55 JLabel iconLabel = new JLabel( icon );
56 iconLabel.setBorder( BorderFactory.createEmptyBorder( 0, 10, 0, 0 ) );
57 add( iconLabel, BorderLayout.EAST );
58 }
59 }
60
61 public void setTitle( String title )
62 {
63 titleLabel.setText( "<html><div style=\"font-size: 9px\"><b>" + title + "</b></div></html>" );
64 }
65
66 public void setDescription( String description )
67 {
68 descriptionLabel.setText( "<html><div style=\"font-size: 9px\">" + description + "</div></html>" );
69 }
70 }