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

📄 common13.java

📁 How to get the java home dir.
💻 JAVA
字号:
package com.mindprod.common13;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 * methods common to all Swing-using programs
 *
 * @noinspection EmptyCatchBlock
 */
public final class Common13
    {
    // ------------------------------ FIELDS ------------------------------

    private static final boolean DEBUGGING = false;
    // -------------------------- PUBLIC STATIC METHODS --------------------------

    /**
     * set the look and feel for a Swing App.
     * Use Nimbus if available, failing that cross platform metal, failing that the default.
     */
    public static void setLaf()
        {
        if ( System.getProperty( "os.name", "unknown" ).equals( "Mac OS X" ) )
            {
            try
                {
                UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
                return;
                }
            catch ( UnsupportedLookAndFeelException e )
                {
                if ( DEBUGGING )
                    {
                    System.err.println( "system L&F failed 1" );
                    }
                }
            catch ( IllegalAccessException e )
                {
                if ( DEBUGGING )
                    {
                    System.err.println( "system L&F failed 2" );
                    }
                }
            catch ( InstantiationException e )
                {
                if ( DEBUGGING )
                    {
                    System.err.println( "system L&F failed 3" );
                    }
                }
            catch ( ClassNotFoundException e )
                {
                if ( DEBUGGING )
                    {
                    System.err.println( "system L&F failed 4" );
                    }
                }
            }

        try
            {
            // Avoid new com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel() to avoid the dreaded
            // NoClassDefFoundError
            UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );
            return;
            }
        catch ( UnsupportedLookAndFeelException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "nimbus L&F failed 1" );
                }
            }
        catch ( IllegalAccessException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "nimbus L&F failed 2" );
                }
            }
        catch ( InstantiationException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "nimbus L&F failed 3" );
                }
            }
        catch ( ClassNotFoundException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "nimbus L&F failed 4" );
                }
            }

        try
            {
            UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
            }
        catch ( UnsupportedLookAndFeelException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "metal L&F failed 1" );
                }
            }
        catch ( IllegalAccessException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "metal L&F failed 2" );
                }
            }
        catch ( InstantiationException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "metal L&F failed 3" );
                }
            }
        catch ( ClassNotFoundException e )
            {
            if ( DEBUGGING )
                {
                System.err.println( "metal L&F failed 4" );
                }
            }

        // give up. leave original L&F in place.
        }

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

    /**
     * test harness
     *
     * @param args not used
     * @noinspection EmptyMethod
     */
    public static void main( String[] args )
        {
        // dummy
        }
    }

⌨️ 快捷键说明

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