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

📄 cmpaboutjbox.java

📁 How to get the java home dir.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        showStatus.setFont( FontFactory.build( "Dialog", Font.BOLD, 12 ) );
        showStatus.setForeground( LABEL_FOREGROUND );
        showStatus.setBackground( WHITE );

        showReleaseDate = new JLabel( "released: " + released, JLabel.CENTER );
        showReleaseDate.setFont( FontFactory.build( "Dialog", Font.PLAIN, 11 ) );
        showReleaseDate.setForeground( LABEL_FOREGROUND );
        showReleaseDate.setBackground( WHITE );

        final String copyright;
        if ( firstCopyrightYear == Build.THIS_COPYRIGHT_YEAR )
            {
            copyright = Integer.toString( Build.THIS_COPYRIGHT_YEAR );
            }
        else
            {
            copyright = firstCopyrightYear + "-" + Build.THIS_COPYRIGHT_YEAR;
            }
        showCopyright = new JLabel( "copyright " + copyright, JLabel.LEFT );
        showCopyright.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
        showCopyright.setForeground( DARK_GREEN );
        showCopyright.setBackground( WHITE );

        showAuthor = new JLabel( author, JLabel.LEFT );
        showAuthor.setFont( FontFactory.build( "Dialog", Font.BOLD + Font.ITALIC, 11 ) );
        showAuthor.setForeground( DARK_GREEN );
        showAuthor.setBackground( WHITE );

        showCMP = new JLabel( "Canadian Mind Products", JLabel.LEFT );
        showCMP.setFont( FontFactory.build( "Dialog", Font.BOLD + Font.ITALIC, 11 ) );
        showCMP.setForeground( DARK_GREEN );
        showCMP.setBackground( WHITE );

        showAddr1 = new JLabel( "#101 - 2536 Wark Street", JLabel.LEFT );
        showAddr1.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
        showAddr1.setForeground( DARK_GREEN );
        showAddr1.setBackground( WHITE );

        showAddr2 = new JLabel( "Victoria, BC Canada V8T 4G8", JLabel.LEFT );
        showAddr2.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
        showAddr2.setForeground( DARK_GREEN );
        showAddr2.setBackground( WHITE );

        showPhone = new JLabel( "phone:(250) 361-9093", JLabel.RIGHT );
        showPhone.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
        showPhone.setForeground( DARK_GREEN );
        showPhone.setBackground( WHITE );

        showMailTo = new JLabel( "roedyg@mindprod.com", JLabel.LEFT );
        showMailTo.setFont( FontFactory.build( "Dialog", Font.ITALIC, 11 ) );
        showMailTo.setForeground( DARK_GREEN );
        showMailTo.setBackground( WHITE );

        showDownloadURL =
                new JLabel( "http://mindprod.com/products.html#" + masterSite,
                        JLabel.RIGHT );
        showDownloadURL.setFont( FontFactory.build( "Dialog", Font.ITALIC, 10 ) );
        showDownloadURL.setForeground( DARK_GREEN );
        showDownloadURL.setBackground( WHITE );

        dismissButton = new JEButton( "Dismiss" );
        dismissButton.requestFocus();
        dismissButton.setToolTipText( "Dismiss About dialog" );

        // add components:

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showprogramVersionBuild,
                new GridBagConstraints( 0,
                        0,
                        2,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.CENTER,
                        GridBagConstraints.NONE,
                        new Insets( 10, 5, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showPurpose1,
                new GridBagConstraints( 0,
                        1,
                        2,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.CENTER,
                        GridBagConstraints.NONE,
                        new Insets( 10, 5, 2, 5 ),
                        0,
                        0 ) );

        if ( purpose2 != null && purpose2.length() > 0 )
            {
            // x y w h wtx wty anchor fill T L B R padx pady
            contentPane.add( showPurpose2,
                    new GridBagConstraints( 0,
                            2,
                            2,
                            1,
                            0.0,
                            0.0,
                            GridBagConstraints.CENTER,
                            GridBagConstraints.NONE,
                            new Insets( 2, 5, 2, 5 ),
                            0,
                            0 ) );
            }

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showStatus,
                new GridBagConstraints( 0,
                        3,
                        2,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.CENTER,
                        GridBagConstraints.NONE,
                        new Insets( 10, 5, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showReleaseDate,
                new GridBagConstraints( 0,
                        4,
                        2,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.CENTER,
                        GridBagConstraints.NONE,
                        new Insets( 2, 5, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showCopyright,
                new GridBagConstraints( 0,
                        5,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showAuthor,
                new GridBagConstraints( 0,
                        6,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showCMP,
                new GridBagConstraints( 0,
                        7,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showAddr1,
                new GridBagConstraints( 0,
                        8,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showAddr2,
                new GridBagConstraints( 0,
                        9,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showPhone,
                new GridBagConstraints( 1,
                        9,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.EAST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 5, 2, 10 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showMailTo,
                new GridBagConstraints( 0,
                        10,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.WEST,
                        GridBagConstraints.NONE,
                        new Insets( 2, 10, 2, 5 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( showDownloadURL,
                new GridBagConstraints( 1,
                        10,
                        1,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.EAST,
                        GridBagConstraints.NONE,
                        new Insets( 5, 5, 5, 10 ),
                        0,
                        0 ) );

        // x y w h wtx wty anchor fill T L B R padx pady
        contentPane.add( dismissButton,
                new GridBagConstraints( 0,
                        11,
                        2,
                        1,
                        0.0,
                        0.0,
                        GridBagConstraints.CENTER,
                        GridBagConstraints.NONE,
                        new Insets( 15, 10, 15, 10 ),
                        0,
                        0 ) );

        // hook up About box listeners

        this.addWindowListener( new WindowAdapter()
        {
        /**
         * Handle request to close about box
         *
         * @param e event giving details of closing.
         */
        public void windowClosing( WindowEvent e )
            {
            dismiss();
            }// end WindowClosing
        }// end anonymous class
        );// end addWindowListener line

        dismissButton.addActionListener( new ActionListener()
        {
        /**
         * close down the About box when user clicks Dismiss
         */
        public void actionPerformed( ActionEvent e )
            {
            Object object = e.getSource();
            if ( object == dismissButton )
                {
                dismiss();
                }// end if
            }// end actionPerformed
        }// end anonymous class
        );// end addActionListener line

        this.validate();
        this.setVisible( true );
        }// end constructor

    // --------------------------- main() method ---------------------------

    /**
     * sample test driver
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        if ( DEBUGGING )
            {
            final JFrame frame = new JFrame( "About box test" );
            frame.setSize( width, height + 26 );

            JMenuBar mb = new JMenuBar();
            frame.setJMenuBar( mb );

            JMenu help = new JMenu( "Help", /* tearoff */false );
            help.getAccessibleContext().setAccessibleDescription( "Help" );

            mb.add( help );

            help.add( new JMenuItem( "keyboard" ) );
            help.add( new JMenuItem( "command line" ) );

            JMenuItem about = new JMenuItem( "About" );
            about.setActionCommand( "About" );
            help.add( about );

            about.addActionListener( new ActionListener()
            {
            /**
             * Handle Menu Selection Request
             *
             * @param e event giving details of selection
             */
            public void actionPerformed( ActionEvent e )
                {
                new CMPAboutJBox( frame,
                        "Sample Amanuensis",
                        "1.0",
                        "Teaches you how to interconvert the 16 basic Java types,",
                        "e.g. String to int, Long to double.",
                        "freeware",
                        "2000-01-01",
                        1996,
                        "Roedy Green",
                        "CONVERTER" );
                }// end ActionListener
            }// end anonymous class
            );// end addActionListener line

            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.validate();
            frame.setVisible( true );
            }// end if
        }// end main
    }

⌨️ 快捷键说明

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