使用Nimbus更改JProgressBar的颜色? [英] Change colors for JProgressBar with Nimbus?
问题描述
有没有人知道如何在使用Nimbus LookAndFeel时更改JProgressBar的颜色?
does anyone know how to change the colors for JProgressBar when you use Nimbus LookAndFeel?
推荐答案
code> nimbusOrange - 默认值,它更改所有ProgressBar-Colors和任何其他 nimbusOrange
。 (InternalFrame - 最小化按钮)
此处以 nimbusBase
(蓝色)
I have overridden the whole nimbusOrange
-Default Value, which change all ProgressBar-Colors and any other nimbusOrange
. (InternalFrame - minimize Button)
here with nimbusBase
(blue)
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
defaults.put("nimbusOrange",defaults.get("nimbusBase"));
Better是写一个自己的Painter并将其设置为 UIManager
通过
Better is to write a own Painter and set this to the UIManager
via
UIManager.put("ProgressBar[Enabled].backgroundPainter", myPainter);
如果要仅更改一个ProgressBar实例的颜色,可以使用组件自定义
If You want to change the Color for only a single ProgressBar instance, you can use Per-component customization
progress = new JProgressBar();
UIDefaults defaults = new UIDefaults();
defaults.put("ProgressBar[Enabled].backgroundPainter", new MyPainter());
progress.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
progress.putClientProperty("Nimbus.Overrides", defaults);
这篇关于使用Nimbus更改JProgressBar的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!