第三方皮肤使用

综合网址:

javootoo.com:http://javootoo.l2fprod.com/index.html

1. Substance look & feel

Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9678341

使用:所有的皮肤都在org.jvnet.substance.skin包下。我们重点关注的是SubstanceLookAndFeel这个类,这个类在org.jvnet.substance包下。这个类是Substance中对皮肤的一个管理类。

所有的皮肤的命名方式为:XXXSkin

与皮肤对应的还有一个是:SubstanceXXXLookAndFeel

注意:上面两个命名中的XXX指的是皮肤的名称也就是下面输出结果中的Key值。

org.jvnet.substance.skin下的所有已LookAndFeel结尾的观感器类都继承了SubstanceLookAndFeel这个类,并加载了对应的默认皮肤。

获取Substance中提供的所有皮肤:

Map<String, SkinInfo> temp = SubstanceLookAndFeel.getAllSkins();
for (Map.Entry<String, SkinInfo> entry : temp.entrySet()) {
	System.out.println("Key = " + entry.getKey() + ", Value = "
			+ entry.getValue().getClassName());
}

输出结果:

Key = Autumn, Value = org.jvnet.substance.skin.AutumnSkin
Key = Business, Value = org.jvnet.substance.skin.BusinessSkin
Key = Business Black Steel, Value = org.jvnet.substance.skin.BusinessBlackSteelSkin
Key = Business Blue Steel, Value = org.jvnet.substance.skin.BusinessBlueSteelSkin
Key = Challenger Deep, Value = org.jvnet.substance.skin.ChallengerDeepSkin
Key = Creme, Value = org.jvnet.substance.skin.CremeSkin
Key = Creme Coffee, Value = org.jvnet.substance.skin.CremeCoffeeSkin
Key = Dust, Value = org.jvnet.substance.skin.DustSkin
Key = Dust Coffee, Value = org.jvnet.substance.skin.DustCoffeeSkin
Key = Emerald Dusk, Value = org.jvnet.substance.skin.EmeraldDuskSkin
Key = Gemini, Value = org.jvnet.substance.api.skin.GeminiSkin
Key = Graphite Aqua, Value = org.jvnet.substance.api.skin.GraphiteAquaSkin
Key = Magellan, Value = org.jvnet.substance.api.skin.MagellanSkin
Key = Magma, Value = org.jvnet.substance.skin.MagmaSkin
Key = Mist Aqua, Value = org.jvnet.substance.skin.MistAquaSkin
Key = Mist Silver, Value = org.jvnet.substance.skin.MistSilverSkin
Key = Moderate, Value = org.jvnet.substance.skin.ModerateSkin
Key = Nebula, Value = org.jvnet.substance.skin.NebulaSkin
Key = Nebula Brick Wall, Value = org.jvnet.substance.skin.NebulaBrickWallSkin
Key = Office Blue 2007, Value = org.jvnet.substance.skin.OfficeBlue2007Skin
Key = Office Silver 2007, Value = org.jvnet.substance.skin.OfficeSilver2007Skin
Key = Raven, Value = org.jvnet.substance.skin.RavenSkin
Key = Raven Graphite, Value = org.jvnet.substance.skin.RavenGraphiteSkin
Key = Raven Graphite Glass, Value = org.jvnet.substance.skin.RavenGraphiteGlassSkin
Key = Sahara, Value = org.jvnet.substance.skin.SaharaSkin
Key = Twilight, Value = org.jvnet.substance.skin.TwilightSkin

上面所列出的就是Substance  所提供的所有皮肤。

1.1 简单的使用

我们直接使用Substance  所提供的默认皮肤,则可以直接使用SubstanceXXXLookAndFeel这类的感官器。

他们的实现模板为:

public class SubstanceXXXLookAndFeel extends SubstanceLookAndFeel {
	public SubstanceXXXLookAndFeel() {
		super(new XXXSkin());
	}
}

因为它们都指定了自己的默认皮肤,所以直接加载就可以了。

SwingUtilities.invokeLater(new Runnable() {
public void run() {
	try {
		UIManager.setLookAndFeel(new SubstanceXXXLookAndFeel());
		//或者写成下面的形式
		UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceXXXLookAndFeel");
	} catch (UnsupportedLookAndFeelException e) {
		e.printStackTrace();
	}
}
});

注意:此时加载出来的皮肤在标题栏是没有改变的,要想发生改变就需要添加下面这句话在main函数中:

JFrame.setDefaultLookAndFeelDecorated(true);
//如果想要让JDialog也改变的话,还要再加上下面这句话 
JDilog.setDefaultLookAndFeelDecorated(true);

1.2 复杂使用

如果我们想在默认的观感效果下更改一下细节,那么我们就必须使用如下方法了:

SwingUtilities.invokeLater(new Runnable() {
	public void run() {
		try {
			UIManager.setLookAndFeel(
					new SubstanceLookAndFeel(new XXXSkin()) {
			});
			//注意:界面的创建必须在这里,否则界面将无法应用皮肤
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
	}
});

上面是制定了皮肤,但是后期想更换皮肤或者是在当前皮肤上做一些修改,这就用到了SubstanceLookAndFeel类中的setSkin()方法,这个方法会更新顶层窗口,但是必须在UIManager.setLookAndFeel()方法之后,否则是无效的。下面是添加背景图片的一个简单用例。

SwingUtilities.invokeLater(new Runnable() {
public void run() {
	JFrame.setDefaultLookAndFeelDecorated(true);
	JDialog.setDefaultLookAndFeelDecorated(true);
	try {
		SubstanceImageWatermark watermark = new SubstanceImageWatermark(
				XXX.class.getResourceAsStream("/demo/001.jpg"));
		watermark.setKind(ImageWatermarkKind.SCREEN_CENTER_SCALE);
		SubstanceSkin skin = new XXXSkin().withWatermark(watermark); // 初始化有水印的皮肤
		UIManager.setLookAndFeel(new SubstanceXXXLookAndFeel());
		SubstanceLookAndFeel.setSkin(skin); // 设置皮肤

	} catch (UnsupportedLookAndFeelException e) {
		e.printStackTrace();
	}
}
});

疑惑点:我们创建GUI界面必须在那个线程之内,那么我要在其它线程就无法使用。为什么必须在这个线程中才可以。

 

2. 3D_LookAndFeel

Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9679927

使用:

UIManager.setLookAndFeel("swing.addon.plaf.threeD.ThreeDLookAndFeel");

3. JTattoo

Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9679946

使用:---->>>>后期补充

4. synthetica

Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9679949

使用:---->>>>后期补充

5. tinylaf

Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9679950

使用:---->>>>后期补充

6. EaSynth

 Jar包下载:http://download.csdn.net/detail/fanxiaobin577328725/9679934

使用:

参考资料:

赞赏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值