[英]Customize Look and feel Nimbus
如何在Nimbus外观中自定义组件的图像? 我想在photoshop中创建图像,并将其放置在某些Nimbus Look and Feel组件上,这些是我要更改的组件:
ScrollBar按钮旋钮ScrollBar拇指ScrollBar ScrollBar轨道
谢谢!
对于灵气的最佳资源是Oracle网站本身在这里 。 但是,它主要概述了通过api自定义主题,并允许通过xml以某种受限的方式通过程序自定义组件,请在此处引用另一篇文章
为了访问和修改您引用的元素,这是一个有用的资源,您可以在此处调用ui管理器以如下方式应用您希望的任何修改:
UIManager.put("nimbusBase", new Color(...)); UIManager.put("nimbusBlueGrey", new Color(...)); UIManager.put("control", new Color(..
再有一个有用的链接这里是进入更多的应用detail.about颜色等,以你的用户界面。
还有漫长的帖子在这里关于使用图像修改的主题,但伊莫你最好的选择将遵循本指南,概述了XML格式plaf.synth这使得XML的装载纯粹是定制的主题,所以非常理想的人谁正在使用photoshop:
<style id="buttonStyle">
<insets top="15" left="20" right="20" bottom="15"/>
<state>
<imagePainter method="buttonBackground" path="images/button.png"
sourceInsets="10 10 10 10"/>
</state>
</style>
<bind style="buttonStyle" type="region" key="button"/>
并获取与您的主题相关的资源:
private static String synthFile = "buttonSkin.xml";
private static void initLookAndFeel() {
// String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
try {
lookAndFeel.load(SynthApplication.class.getResourceAsStream(synthFile),
SynthApplication.class);
UIManager.setLookAndFeel(lookAndFeel);
}
catch (Exception e) {
System.err.println("Couldn't get specified look and feel ("
+ lookAndFeel
+ "), for some reason.");
System.err.println("Using the default look and feel.");
e.printStackTrace();
}
}
完整样本在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.