⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmpaboutjbox.java

📁 How to get the java home dir.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.mindprod.common13;

import com.mindprod.common11.Build;
import com.mindprod.common11.FontFactory;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * A Swing About box that truly tells you about he program, not just the author's name.
 *
 * @author Roedy Green
 * @noinspection FieldCanBeLocal
 * @see com.mindprod.common11.CMPAboutBox
 */
public final class CMPAboutJBox extends JDialog
    {
    // ------------------------------ FIELDS ------------------------------

    /**
     * true if want debugging output
     */
    private static final boolean DEBUGGING = false;

    /**
     * height of Dialog box in pixels. Does not include surrounding frame.
     *
     * @noinspection ConstantNamingConvention
     */
    private static final int height = 360;

    /**
     * Width of Dialog box in pixels.
     *
     * @noinspection ConstantNamingConvention
     */
    private static final int width = 480;

    private static final Color BLACK = Color.black;

    private static final Color DARK_GREEN = new Color( 0x008000 );

    private static final Color LABEL_FOREGROUND = new Color( 0x0000b0 );

    /**
     * for titles
     */
    private static final Color TITLE_FOREGROUND = new Color( 0xdc143c );

    private static final Color WHITE = Color.white;

    /**
     * for for titles and About buttons
     */
    private static final Font TITLE_FONT = FontFactory.build( "Dialog", Font.BOLD, 16 );

    /**
     * trigger dismiss of about box
     */
    private JButton dismissButton;

    /**
     * first line of CMP mailing address
     */
    private JLabel showAddr1;

    /**
     * second line of CMP mailing address
     */
    private JLabel showAddr2;

    /**
     * program author
     */
    private JLabel showAuthor;

    /**
     * Canadian Mind Products
     */
    private JLabel showCMP;

    /**
     * copyright
     */
    private JLabel showCopyright;

    /**
     * download url
     */
    private JLabel showDownloadURL;

    /**
     * contact email
     */
    private JLabel showMailTo;

    /**
     * cmp phone
     */
    private JLabel showPhone;

    /**
     * program name and version
     */
    private JLabel showprogramVersionBuild;

    /**
     * first line of purpose
     */
    private JLabel showPurpose1;

    /**
     * second line of purpose
     */
    private JLabel showPurpose2;

    /**
     * date released yyyy-mm-dd
     */
    private JLabel showReleaseDate;

    /**
     * freeware, shareware etc.
     */
    private JLabel showStatus;

    // -------------------------- PUBLIC INSTANCE  METHODS --------------------------
    /**
     * Create an about box, no parent, assumes Roedy Green as author
     *
     * @param progname           Program name
     * @param version            Program version e.g. "1.3"
     * @param purpose1           what is this program for? line-1
     * @param purpose2           what is this program for? line-2. may be null, or "".
     * @param status             e.g. "unregistered shareware", "freeware", "commercial", "company confidential"
     * @param released           Date released e.g. "1999-12-31"
     * @param firstCopyrightYear e.g. 1996
     * @param masterSite         anchor on products page e.g. CONVERTER -- where to find most up to date ZIP
     */
    public CMPAboutJBox( final String progname,
                         final String version,
                         final String purpose1,
                         final String purpose2,
                         final String status,
                         final String released,
                         final int firstCopyrightYear,
                         final String masterSite )
        {
        // dummy frame won't be properly disposed
        this( new JFrame( progname + " " + version + " build " + Build.BUILD_NUMBER ),
                progname,
                version,
                purpose1,
                purpose2,
                status,
                released,
                firstCopyrightYear,
                "Roedy Green",
                masterSite );
        }

    /**
     * Create an about box, with default author Roedy Green
     *
     * @param parent             frame for this about box.
     * @param progname           Program name
     * @param version            Program version e.g. "1.3"
     * @param purpose1           what is this program for? line-1
     * @param purpose2           what is this program for? line-2. may be null, or "".
     * @param status             e.g. "unregistered shareware", "freeware", "commercial", "company confidential"
     * @param released           Date released e.g. "1999-12-31"
     * @param firstCopyrightYear e.g. 1996
     * @param masterSite         anchor on products page e.g. CONVERTER -- where to find most up to date ZIP
     * @noinspection UnusedDeclaration
     */
    public CMPAboutJBox( final JFrame parent,
                         final String progname,
                         final String version,
                         final String purpose1,
                         final String purpose2,
                         final String status,
                         final String released,
                         final int firstCopyrightYear,
                         final String masterSite )
        {
        this( parent,
                progname,
                version,
                purpose1,
                purpose2,
                status,
                released,
                firstCopyrightYear,
                "Roedy Green",
                masterSite );
        }

    /**
     * Create an about box, no parent
     *
     * @param progname           Program name
     * @param version            Program version e.g. "1.3"
     * @param purpose1           what is this program for? line-1
     * @param purpose2           what is this program for? line-2. may be null, or "".
     * @param status             e.g. "unregistered shareware", "freeware", "commercial", "company confidential"
     * @param released           Date released e.g. "1999-12-31"
     * @param firstCopyrightYear e.g. 1996
     * @param author             program's author
     * @param masterSite         anchor on products page e.g. CONVERTER -- where to find most up to date ZIP
     * @noinspection UnusedDeclaration
     */
    public CMPAboutJBox( final String progname,
                         final String version,
                         final String purpose1,
                         final String purpose2,
                         final String status,
                         final String released,
                         final int firstCopyrightYear,
                         final String author,
                         final String masterSite )
        {
        // dummy frame won't be properly disposed
        this( new JFrame( progname + " " + version + " build " + Build.BUILD_NUMBER ),
                progname,
                version,
                purpose1,
                purpose2,
                status,
                released,
                firstCopyrightYear,
                author,
                masterSite );
        }

    /**
     * Create an about box
     *
     * @param parent             frame for this about box.
     * @param progname           Program name
     * @param version            Program version e.g. "1.3"
     * @param purpose1           what is this program for? line-1
     * @param purpose2           what is this program for? line-2. may be null, or "".
     * @param status             e.g. "unregistered shareware", "freeware", "commercial", "company confidential"
     * @param released           Date released e.g. "1999-12-31"
     * @param firstCopyrightYear e.g. 1996
     * @param author             program's author
     * @param masterSite         anchor on products page e.g. CONVERTER -- where to find most up to date ZIP
     */
    public CMPAboutJBox( final Frame parent,
                         final String progname,
                         final String version,
                         final String purpose1,
                         final String purpose2,
                         final String status,
                         final String released,
                         final int firstCopyrightYear,
                         final String author,
                         final String masterSite )
        {
        super( parent,
                progname + " " + version + " build " + Build.BUILD_NUMBER,
                false
                /* not modal */ );
        guts( progname,
                version,
                purpose1,
                purpose2,
                status,
                released,
                firstCopyrightYear,
                author,
                masterSite );
        }

    // -------------------------- OTHER METHODS --------------------------

    /**
     * Shutdown the about box
     */
    private void dismiss()
        {
        this.dispose();
        }// end dismiss

    /**
     * Create an about box
     *
     * @param progname           Program name
     * @param version            Program version e.g. "1.3"
     * @param purpose1           what is this program for? line-1
     * @param purpose2           what is this program for? line-2. may be null, or "".
     * @param status             e.g. "unregistered shareware", "freeware", "commercial", "company confidential"
     * @param released           Date released e.g. "1999-12-31"
     * @param firstCopyrightYear e.g. 1996
     * @param masterSite         anchor on products page e.g. CONVERTER -- where to find most up to date ZIP
     * @param author             who wrote the program.
     */
    private void guts( final String progname,
                       final String version,
                       final String purpose1,
                       final String purpose2,
                       final String status,
                       final String released,
                       final int firstCopyrightYear,
                       final String author,
                       final String masterSite )
        {
        // basic layout
        // 0 1
        // 0 ---------------progname version--------------------------------- 0
        //
        // 1 ---------------------purpose1------------------------------------ 1
        // 2 ---------------------purpose2------------------------------------ 2
        //
        // 3 ---------------------status-------------------------------------- 3
        // 4 --------------released: xxxxxxxxx-------------------------------- 4
        //
        // 5 copyright (c) 2006-20085
        // 6 Roedy Green 6
        // 7 Canadian Mind Products 7
        // 8 #101 - 2536 Wark Street 8
        // 9 Victoria, BC Canada V8T 4G8 phone:(250) 361-9093 9
        // 10 roedyg@mindprod.com http://mindprod.com/products#CONVERTER 10
        //
        // 11 (Dismiss) 11
        // 0 1

        setSize( width, height );
        setLocation( 0, 0 );

        Container contentPane = this.getContentPane();
        contentPane.setBackground( WHITE );

        contentPane.setLayout( new GridBagLayout() );

        showprogramVersionBuild =
                new JLabel( progname + " " + version + " build " + Build.BUILD_NUMBER,
                        JLabel.CENTER );
        showprogramVersionBuild.setFont( TITLE_FONT );
        showprogramVersionBuild.setForeground( TITLE_FOREGROUND );
        showprogramVersionBuild.setBackground( WHITE );

        showPurpose1 = new JLabel( purpose1, JLabel.CENTER );
        showPurpose1.setFont( FontFactory.build( "Dialog", Font.ITALIC, 12 ) );
        showPurpose1.setForeground( BLACK );
        showPurpose1.setBackground( WHITE );

        if ( purpose2 != null && purpose2.length() > 0 )
            {
            showPurpose2 = new JLabel( purpose2, JLabel.CENTER );
            showPurpose2.setFont( FontFactory.build( "Dialog", Font.ITALIC, 12 ) );
            showPurpose2.setForeground( BLACK );
            showPurpose2.setBackground( WHITE );
            }

        showStatus = new JLabel( status, JLabel.CENTER );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -