Custom Painter on JProgressBar

你。 提交于 2019-12-05 15:26:32

I had a similar program myself.

Can't remember the actual code though.

but i had to get the UI properties, overwrite the colour and reapply them.

I was using netbeans at the time, and changing the colour field from the properties was not effecting it since the Nimbus UI was set.

Try changing the ui to other ones and see if the colour is allowed to change. I'll search for the code i had used at the time in the mean time.

found it

UIDefaults defaults = UIManager.getLookAndFeelDefaults();
defaults.put("nimbusOrange", new Color(0, 0, 255));
progressBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
progressBar.putClientProperty("Nimbus.Overrides", defaults);

where progressBar is the JProgressBar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!