Pregunta

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?

¿Fue útil?

Solución

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());
}

Otros consejos

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top