    001    /* ========================================================================
    002     * JCommon : a free general purpose class library for the Java(tm) platform
    003     * ========================================================================
    004     *
    005     * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
    006     *
    007     * Project Info:  http://www.jfree.org/jcommon/index.html
    008     *
    009     * This library is free software; you can redistribute it and/or modify it
    010     * under the terms of the GNU Lesser General Public License as published by
    011     * the Free Software Foundation; either version 2.1 of the License, or
    012     * (at your option) any later version.
    013     *
    014     * This library is distributed in the hope that it will be useful, but
    015     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    016     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    017     * License for more details.
    018     *
    019     * You should have received a copy of the GNU Lesser General Public
    020     * License along with this library; if not, write to the Free Software
    021     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
    022     * USA.
    023     *
    024     * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
    025     * in the United States and other countries.]
    026     *
    027     * ---------------
    028     * AboutPanel.java
    029     * ---------------
    030     * (C) Copyright 2001-2004, by Object Refinery Limited.
    031     *
    032     * Original Author:  David Gilbert (for Object Refinery Limited);
    033     * Contributor(s):   -;
    034     *
    035     * $Id: AboutPanel.java,v 1.3 2005/10/18 13:19:13 mungady Exp $
    036     *
    037     * Changes (from 26-Oct-2001)
    038     * --------------------------
    039     * 26-Nov-2001 : Version 1 (DG);
    040     * 27-Jun-2002 : Added logo (DG);
    041     * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
    042     *
    043     */
    044
    045    package org.jfree.ui.about;
    046
    047    import java.awt.BorderLayout;
    048    import java.awt.Color;
    049    import java.awt.Font;
    050    import java.awt.GridLayout;
    051    import java.awt.Image;
    052
    053    import javax.swing.BorderFactory;
    054    import javax.swing.JLabel;
    055    import javax.swing.JPanel;
    056    import javax.swing.SwingConstants;
    057
    058    import org.jfree.ui.RefineryUtilities;
    059
    060    /**
    061     * A standard panel for displaying information about an application.
    062     *
    063     * @author David Gilbert
    064     */
    065    public class AboutPanel extends JPanel {
    066
    067        /**
    068         * Constructs a panel.
    069         *
    070         * @param application  the application name.
    071         * @param version  the version.
    072         * @param copyright  the copyright statement.
    073         * @param info  other info.
    074         */
    075        public AboutPanel(final String application, final String version, final String copyright, final String info) {
    076
    077            this(application, version, copyright, info, null);
    078
    079        }
    080
    081        /**
    082         * Constructs a panel.
    083         *
    084         * @param application  the application name.
    085         * @param version  the version.
    086         * @param copyright  the copyright statement.
    087         * @param info  other info.
    088         * @param logo  an optional logo.
    089         */
    090        public AboutPanel(final String application, final String version, final String copyright, final String info,
    091                          final Image logo) {
    092
    093            setLayout(new BorderLayout());
    094
    095            final JPanel textPanel = new JPanel(new GridLayout(4, 1, 0, 4));
    096
    097            final JPanel appPanel = new JPanel();
    098            final Font f1 = new Font("Dialog", Font.BOLD, 14);
    099            final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black);
    100            appLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    101            appPanel.add(appLabel);
    102
    103            final JPanel verPanel = new JPanel();
    104            final Font f2 = new Font("Dialog", Font.PLAIN, 12);
    105            final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black);
    106            verLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    107            verPanel.add(verLabel);
    108
    109            final JPanel copyrightPanel = new JPanel();
    110            final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black);
    111            copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    112            copyrightPanel.add(copyrightLabel);
    113
    114            final JPanel infoPanel = new JPanel();
    115            final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black);
    116            infoLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    117            infoPanel.add(infoLabel);
    118
    119            textPanel.add(appPanel);
    120            textPanel.add(verPanel);
    121            textPanel.add(copyrightPanel);
    122            textPanel.add(infoPanel);
    123
    124            add(textPanel);
    125
    126            if (logo != null) {
    127                final JPanel imagePanel = new JPanel(new BorderLayout());
    128                imagePanel.add(new javax.swing.JLabel(new javax.swing.ImageIcon(logo)));
    129                imagePanel.setBorder(BorderFactory.createLineBorder(Color.black));
    130                final JPanel imageContainer = new JPanel(new BorderLayout());
    131                imageContainer.add(imagePanel, BorderLayout.NORTH);
    132                add(imageContainer, BorderLayout.WEST);
    133            }
    134
    135        }
    136
    137    }