I'm using nimbus lookAndFill
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
and my indeterminate JProgressBar looks like that:
http://img15.imageshack.us/img15/9470/uglyprogress.jpg
can i make it looks better?
I'm using nimbus lookAndFill
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
and my indeterminate JProgressBar looks like that:
http://img15.imageshack.us/img15/9470/uglyprogress.jpg
can i make it looks better?
有一个更简单的解决方案。您可以在设置 nimbus 外观之前复制进度条 UI 默认值,然后再将它们设置回来。然后,您将获得 Nimbus 的外观和感觉,但没有进度条样式。
// copy progress bar defaults
HashMap<Object, Object> progressDefaults = new HashMap<>();
for(Map.Entry<Object, Object> entry : UIManager.getDefaults().entrySet()){
if(entry.getKey().getClass() == String.class && ((String)entry.getKey()).startsWith("ProgressBar")){
progressDefaults.put(entry.getKey(), entry.getValue());
}
}
// set nimbus
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
// copy back progress bar defaults
for(Map.Entry<Object, Object> entry : progressDefaults.entrySet()){
UIManager.getDefaults().put(entry.getKey(), entry.getValue());
}
您可以使用不同的外观和填充,也可以创建自己的组件。