http://www.qumake.com/articles/2011/04/18/1303094833690.html
————————————————————————————————————————————————————————————————————————————
在Substance6之前, skin 有一个withWatermark 方法来设置皮肤水印。
try{
SubstanceImageWatermark watermark = new SubstanceImageWatermark(this.getClass().getResourceAsStream("watermark.jpg"));
SubstanceImageWatermark.setKind(ImageWatermarkKind.SCREEN_CENTER_SCALE);
SubstanceSkin skin = new BusinessBlackSteelSkin().withWatermark(watermark); //初始化有水印地皮肤
UIManager.setLookAndFeel(new SubstanceSaharaLookAndFeel());
SubstanceLookAndFeel.setSkin(skin); //配置皮肤
}catch(UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
在Substance 6中这个方法没有了,看到很多人都在问Substance 6中怎么设置水印,所以写一下。其实, Substance 中官方带的例子很详细,里面都有哦。
1。首先要继承substance 中的skin, 加入自己的watermark.
class MySkin extends org.pushingpixels.substance.api.skin.BusinessBlackSteelSkin{
public MySkin(){
super();
SubstanceImageWatermark imageWatermark = new
SubstanceImageWatermark(this.getClass().getResourceAsStream("/ICON-INF/watermark.jpg"));
imageWatermark.setOpacity(0.7f);
imageWatermark.setKind(ImageWatermarkKind.APP_ANCHOR);
this.watermark = imageWatermark;
}
}
2.然后给要水印效果的组件的设置属性。
mainFrame.getRootPane().putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, true);
3.最后就是设置皮肤了。
SubstanceLookAndFeel.setSkin(new MySkin);