覆盖每个组件实例的 Swing Nimbus L&F 原色
我试图覆盖 JButton/JTabbedPane 特定实例的“nimbusBase”颜色,但没有成功。 只有组件的特定属性(例如“Button.background”)起作用。 有什么想法吗?
UIDefaults dialogTheme = new UIDefaults();
// dialogTheme.put(“nimbusBase”, Color.orange);
// dialogTheme.put("nimbusBlueGrey", Color.blue);
dialogTheme.put("Button.background", Color.yellow);
JButton dialogButton = new JButton("North");
dialogButton.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
dialogButton.putClientProperty("Nimbus.Overrides", dialogTheme);
i’m trying to override the “nimbusBase” color for specific instance of JButton/JTabbedPane with no luck.
only the specific attributes of the component e.g. “Button.background”, are working.
any idea?
UIDefaults dialogTheme = new UIDefaults();
// dialogTheme.put(“nimbusBase”, Color.orange);
// dialogTheme.put("nimbusBlueGrey", Color.blue);
dialogTheme.put("Button.background", Color.yellow);
JButton dialogButton = new JButton("North");
dialogButton.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
dialogButton.putClientProperty("Nimbus.Overrides", dialogTheme);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将颜色放置到所有组件“nimbusBase”的 LookAndFeelDefaults 中
,或者放置到您编写的特定组件中。也许更新 componentTreeUI。
我从不覆盖特定组件的
"nimbusBase"
。我找到了一个不错的 Nimbus Theme Creator,它可以显示更改 Nimbus 的效果所有组件的默认颜色:http://aephyr.googlecode.com/svn/trunk
编辑
您可以“复制”Painter,修改它们并通过 UIDefaults 设置它们:
示例 GUI一个 nimbusOrange JTabbedPane 和一个普通的 JTabbedPane。
使用 nimbusOrange 的 Painter 类
注意:我删除了此 Painter 示例中的绘制方法。因为这段代码太长了。只需通过
com.sun.java.swing.plaf.nimbus.TabbedPaneTabbedPaneTabPainter
的复制并粘贴即可添加它们。AreaPainter 与 numbusOrange
You can put the Color to the
LookAndFeelDefaults
for all Components "nimbusBase"Or to a specific Component as you wrote it. Perhaps with update the componentTreeUI.
I never override
"nimbusBase"
for a specific Component.I found a nice Nimbus Theme Creator, which can show the effect of changing a Nimbus Default Color to all Components: http://aephyr.googlecode.com/svn/trunk
EDIT
You can 'copy' the Painter, modify them and set them via UIDefaults:
Example GUI with an nimbusOrange JTabbedPane and a normal one.
Painter class with nimbusOrange
NOTE: I removed the paint methods in this Painter example. Because this code was to long. Just add them via copy&past from
com.sun.java.swing.plaf.nimbus.TabbedPaneTabbedPaneTabPainter
.AreaPainter with numbusOrange