swing美化包的应用

时间:2023-01-28 07:35:21

是不是厌倦了JAVA中AWT与swing的呆板,那就用美化的皮肤包来是你的界面更加的精美吧!!!

本篇主要介绍两种美化的皮肤包:substance.jar和jtattoo.jar

皮肤包可以美化swing,在main()中加入下面的话,加try-catch
UIManager.setLookAndFeel(new SubstanceLookAndFeel());


jtattoo.jar包:
(将下面其中的一个替换上面例程中主函数try块的UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");中相应的代码即可换肤).
com.jtattoo.plaf.noire.NoireLookAndFeel  柔和黑
com.jtattoo.plaf.smart.SmartLookAndFeel 木质感+xp风格
com.jtattoo.plaf.mint.MintLookAndFeel  椭圆按钮+黄色按钮背景
com.jtattoo.plaf.mcwin.McWinLookAndFeel 椭圆按钮+绿色按钮背景
com.jtattoo.plaf.luna.LunaLookAndFeel  纯XP风格
com.jtattoo.plaf.hifi.HiFiLookAndFeel  黑色风格
com.jtattoo.plaf.fast.FastLookAndFeel  普通swing风格+蓝色边框
com.jtattoo.plaf.bernstein.BernsteinLookAndFeel  黄色风格
com.jtattoo.plaf.aluminium.AluminiumLookAndFeel 椭圆按钮+翠绿色按钮背景+金属质感
com.jtattoo.plaf.aero.AeroLookAndFeel xp清新风格
com.jtattoo.plafacryl.AcrylLookAndFeel 布质感+swing纯风格
com.jtattoo.plaf.graphite.GraphiteLookAndFeel








substance.jar包:
 try {
            //设置外观
            UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
            JFrame.setDefaultLookAndFeelDecorated(true);
            //设置主题 
            SubstanceLookAndFeel.setCurrentTheme(new SubstanceEbonyTheme());
            //设置按钮外观
            SubstanceLookAndFeel.setCurrentButtonShaper(new ClassicButtonShaper());
            //设置水印
            SubstanceLookAndFeel.setCurrentWatermark(new SubstanceBinaryWatermark());
            //设置边框
            SubstanceLookAndFeel.setCurrentBorderPainter(new StandardBorderPainter());
            //设置渐变渲染
            SubstanceLookAndFeel.setCurrentGradientPainter(new StandardGradientPainter());
            //设置标题
            SubstanceLookAndFeel.setCurrentTitlePainter(new FlatTitlePainter());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }




substance.jar包:
皮肤:解压JAR文件,可以看到在“org/jvnet/substance/skin”下有下面这些皮肤
使用:
要使用上述皮肤很简单,只要在main函数中调用下面代码即可:




//主要设置皮肤、主题还有按钮、水印、选项卡、滑动条以及水印等


//UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel");


//UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel");


//UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceSaharaLookAndFeel");


//UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel");


UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel");
皮肤22种:
SubstanceAutumnLookAndFeel.class


SubstanceBusinessBlackSteelLookAndFeel.class


SubstanceBusinessBlueSteelLookAndFeel.class


SubstanceBusinessLookAndFeel.class


SubstanceChallengerDeepLookAndFeel.class


SubstanceCremeLookAndFeel.class


SubstanceEmeraldDuskLookAndFeel.class


SubstanceFieldOfWheatLookAndFeel.class


SubstanceGreenMagicLookAndFeel.class


SubstanceMagmaLookAndFeel.class


SubstanceMangoLookAndFeel.class


SubstanceMistAquaLookAndFeel.class


SubstanceMistSilverLookAndFeel.class


SubstanceModerateLookAndFeel.class


SubstanceNebulaBrickWallLookAndFeel.class


SubstanceNebulaLookAndFeel.class


SubstanceOfficeBlue2007LookAndFeel.class


SubstanceOfficeSilver2007LookAndFeel.class


SubstanceRavenGraphiteGlassLookAndFeel.class


SubstanceRavenGraphiteLookAndFeel.class


SubstanceRavenLookAndFeel.class


SubstanceSaharaLookAndFeel.class




主题:
2. org/jvnet/substance/theme 下有所有可用的主题:
改变主题:
改变界面的默认主题也很简单,只需要加上以下代码就可以了(不过貌似5.0以上没有这个方法了,且substance下也没有theme文件夹了)。另外5.0版本以上必须将这些语句置于




java.awt.EventQueue.invokeLater(new Runnable() {


public void run() {


   //此处设置皮肤和主题


});


的run方法中,否则会出错。




SubstanceLookAndFeel.setCurrentTheme("org.jvnet.substance.theme.SubstanceDarkVioletTheme");


另外如果想让整体界面变得协调,最好设置容器窗体的DefaultLookAndFeelDecorated属性为true。




JFrame.setDefaultLookAndFeelDecorated(true);


JDialog.setDefaultLookAndFeelDecorated(true);




SubstanceAquaTheme.class


SubstanceBarbyPinkTheme.class


SubstanceBlendBiTheme.class


SubstanceBottleGreenTheme.class


SubstanceBrownTheme.class


SubstanceCharcoalTheme.class


SubstanceColorBlindTheme.class


SubstanceComplexTheme.class


SubstanceCremeTheme.class


SubstanceDarkVioletTheme.class


SubstanceDesertSandTheme.class


SubstanceDeuteranopiaTheme.class


SubstanceEbonyTheme.class


SubstanceHueShiftTheme.class


SubstanceInvertedTheme.class


SubstanceJadeForestTheme.class


SubstanceLightAquaTheme.class


SubstanceLimeGreenTheme.class


SubstanceMixBiTheme.class


SubstanceMixTheme.class


SubstanceNegatedTheme.class


SubstanceOliveTheme.class


SubstanceOrangeTheme.class


SubstanceProtanopiaTheme.class


SubstancePurpleTheme.class


SubstanceRaspberryTheme.class


SubstanceSaturatedTheme.class


SubstanceSepiaTheme.class


SubstanceShadeTheme.class


SubstanceSteelBlueTheme.class


SubstanceSunGlareTheme.class


SubstanceSunsetTheme.class


SubstanceTerracottaTheme.class


SubstanceTheme$1$1.class


SubstanceTheme$1.class


SubstanceTheme$10.class


SubstanceTheme$11.class


SubstanceTheme$12.class


SubstanceTheme$13.class


SubstanceTheme$14.class


SubstanceTheme$15.class


SubstanceTheme$16.class


SubstanceTheme$17.class


SubstanceTheme$18.class


SubstanceTheme$19.class


SubstanceTheme$2.class


SubstanceTheme$20.class


SubstanceTheme$21.class


SubstanceTheme$22.class


SubstanceTheme$23.class


SubstanceTheme$24.class


SubstanceTheme$25.class


SubstanceTheme$26.class


SubstanceTheme$27.class


SubstanceTheme$28.class


SubstanceTheme$3.class


SubstanceTheme$4.class


SubstanceTheme$5.class


SubstanceTheme$6.class


SubstanceTheme$7.class


SubstanceTheme$8.class


SubstanceTheme$9.class


SubstanceTheme$ThemeKind.class


SubstanceTheme.class


SubstanceTintTheme.class


SubstanceToneTheme.class


SubstanceTritanopiaTheme.class


SubstanceUltramarineTheme.class


SubstanceWrapperTheme.class