Source for org.jfree.ui.about.AboutPanel

   1: /* ========================================================================
   2:  * JCommon : a free general purpose class library for the Java(tm) platform
   3:  * ========================================================================
   4:  *
   5:  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
   6:  * 
   7:  * Project Info:  http://www.jfree.org/jcommon/index.html
   8:  *
   9:  * This library is free software; you can redistribute it and/or modify it 
  10:  * under the terms of the GNU Lesser General Public License as published by 
  11:  * the Free Software Foundation; either version 2.1 of the License, or 
  12:  * (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but 
  15:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  16:  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
  17:  * License for more details.
  18:  *
  19:  * You should have received a copy of the GNU Lesser General Public
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  * 
  27:  * ---------------
  28:  * AboutPanel.java
  29:  * ---------------
  30:  * (C) Copyright 2001-2004, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: AboutPanel.java,v 1.6 2007/11/02 17:50:36 taqua Exp $
  36:  *
  37:  * Changes (from 26-Oct-2001)
  38:  * --------------------------
  39:  * 26-Nov-2001 : Version 1 (DG);
  40:  * 27-Jun-2002 : Added logo (DG);
  41:  * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
  42:  *
  43:  */
  44: 
  45: package org.jfree.ui.about;
  46: 
  47: import java.awt.BorderLayout;
  48: import java.awt.Color;
  49: import java.awt.Font;
  50: import java.awt.GridLayout;
  51: import java.awt.Image;
  52: import javax.swing.BorderFactory;
  53: import javax.swing.JLabel;
  54: import javax.swing.JPanel;
  55: import javax.swing.SwingConstants;
  56: 
  57: import org.jfree.ui.RefineryUtilities;
  58: 
  59: /**
  60:  * A standard panel for displaying information about an application.
  61:  *
  62:  * @author David Gilbert
  63:  */
  64: public class AboutPanel extends JPanel {
  65: 
  66:     /**
  67:      * Constructs a panel.
  68:      *
  69:      * @param application  the application name.
  70:      * @param version  the version.
  71:      * @param copyright  the copyright statement.
  72:      * @param info  other info.
  73:      */
  74:     public AboutPanel(final String application,
  75:                       final String version,
  76:                       final String copyright,
  77:                       final String info) {
  78: 
  79:         this(application, version, copyright, info, null);
  80: 
  81:     }
  82: 
  83:     /**
  84:      * Constructs a panel.
  85:      *
  86:      * @param application  the application name.
  87:      * @param version  the version.
  88:      * @param copyright  the copyright statement.
  89:      * @param info  other info.
  90:      * @param logo  an optional logo.
  91:      */
  92:     public AboutPanel(final String application,
  93:                       final String version,
  94:                       final String copyright,
  95:                       final String info,
  96:                       final Image logo) {
  97: 
  98:         setLayout(new BorderLayout());
  99: 
 100:         final JPanel textPanel = new JPanel(new GridLayout(4, 1, 0, 4));
 101: 
 102:         final JPanel appPanel = new JPanel();
 103:         final Font f1 = new Font("Dialog", Font.BOLD, 14);
 104:         final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black);
 105:         appLabel.setHorizontalTextPosition(SwingConstants.CENTER);
 106:         appPanel.add(appLabel);
 107: 
 108:         final JPanel verPanel = new JPanel();
 109:         final Font f2 = new Font("Dialog", Font.PLAIN, 12);
 110:         final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black);
 111:         verLabel.setHorizontalTextPosition(SwingConstants.CENTER);
 112:         verPanel.add(verLabel);
 113: 
 114:         final JPanel copyrightPanel = new JPanel();
 115:         final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black);
 116:         copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER);
 117:         copyrightPanel.add(copyrightLabel);
 118: 
 119:         final JPanel infoPanel = new JPanel();
 120:         final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black);
 121:         infoLabel.setHorizontalTextPosition(SwingConstants.CENTER);
 122:         infoPanel.add(infoLabel);
 123: 
 124:         textPanel.add(appPanel);
 125:         textPanel.add(verPanel);
 126:         textPanel.add(copyrightPanel);
 127:         textPanel.add(infoPanel);
 128: 
 129:         add(textPanel);
 130: 
 131:         if (logo != null) {
 132:             final JPanel imagePanel = new JPanel(new BorderLayout());
 133:             imagePanel.add(new javax.swing.JLabel(new javax.swing.ImageIcon(logo)));
 134:             imagePanel.setBorder(BorderFactory.createLineBorder(Color.black));
 135:             final JPanel imageContainer = new JPanel(new BorderLayout());
 136:             imageContainer.add(imagePanel, BorderLayout.NORTH);
 137:             add(imageContainer, BorderLayout.WEST);
 138:         }
 139: 
 140:     }
 141: 
 142: }