View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
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  }