当前位置: 首页 > 工具软件 > jTattoo > 使用案例 >

Java界面美化--substance.jar和JTattoo.jar包的使用

佟高澹
2023-12-01

substance.jar包的使用

1、将substance.jar添加到类路径中
2、将下列代码添加到你的程序的主执行类的main()方法中:

try {
            UIManager.setLookAndFeel(new SubstanceLookAndFeel());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            SubstanceLookAndFeel.setCurrentTheme(new SubstanceTerracottaTheme());
//          SubstanceLookAndFeel.setSkin(new EmeraldDuskSkin());
//          SubstanceLookAndFeel.setCurrentButtonShaper(new ClassicButtonShaper());
//          SubstanceLookAndFeel.setCurrentWatermark(new SubstanceBubblesWatermark());
//          SubstanceLookAndFeel.setCurrentBorderPainter(new StandardBorderPainter());
//          SubstanceLookAndFeel.setCurrentGradientPainter(new StandardGradientPainter());
//          SubstanceLookAndFeel.setCurrentTitlePainter(new FlatTitePainter());
        } catch (Exception e) {
            System.err.println("Something went wrong!");
 }

        这个地方主要介绍一下关于使用substance.jar包装程序时对界面效果的几个方面的设置,主要要主题,皮肤,按钮类型,水印,边框渲染,渐变渲染与标题栏渲染.

共有22种皮肤,69种主题。

1. 下载下来substance.jar包后,解压JAR文件,可以看到在“org/jvnet/substance/skin”下有下面这些皮肤(以LookAndFeel.class结尾的文件)。

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

要使用上述皮肤很简单,只要在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");

2. org/jvnet/substance/theme 下有所有可用的主题:

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

改变界面的默认主题也很简单,只需要加上以下代码就可以了(不过貌似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);


当然除了设置皮肤和主题外,还可以设置按钮、水印、选项卡、滑动条以及水印、字体、标题等的观感。具体的可以查看substance\org\jvnet\substance目录。方法同上面讲的一样。


JTattoo.jar包的使用

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包和JTattoo.jar包的下载

 类似资料: