1

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Adir
  • 55
  • 1
  • 6

2 Answers2

3

There's an easier solution. You can just copy the progress bar UI defaults before setting the nimbus look-and-feel and then set them back after. You then get Nimbus look and feel but without its progress bar styling.

// 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());
}
Philip Welch
  • 4,488
  • 2
  • 20
  • 17
  • I found the best solution, based on your! *//setting NimbusLookAndFeel*
    UIManager.setLookAndFeel(new NimbusLookAndFeel()); *// setting other progress bar l&f*
    processingJProgressBar.**setUI**(new WebProgressBarUI());
    – Adir Oct 12 '13 at 17:35
2

You can either use a different look and fill or create your own component.

Community
  • 1
  • 1
0x6C38
  • 6,796
  • 4
  • 35
  • 47