Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6737577

JProgressBar is not updated correctly

XMLWordPrintable

      During out work on the NetBeans Installer we`ve got several issues reported that said that JProgressBar is not updated correctly on Ubuntu (7.xx, 8.xx) with KDE as the desktop manager and using GTKLookAndFeel.
      The percentage is changing but the bar is not moving.
      http://www.netbeans.org/issues/show_bug.cgi?id=122970
      http://www.netbeans.org/issues/show_bug.cgi?id=117525
      http://www.netbeans.org/issues/show_bug.cgi?id=140509
      http://www.netbeans.org/issues/show_bug.cgi?id=107258

      The short list of the screenshots:
      http://www.netbeans.org/nonav/issues/showattachment.cgi/43974/screen.bmp
      http://www.netbeans.org/nonav/issues/showattachment.cgi/53602/instProgress1.png
      http://www.netbeans.org/nonav/issues/showattachment.cgi/50037/netbeans6b1installer.jpg
      http://www.netbeans.org/nonav/issues/showattachment.cgi/57423/nb-install-progress.png

      There is bug 4101914 which is filed long ago and the symptom data is the same.

      As for now, I`ve finally got one such system (in SWAN) where this issue is always reproducible.
      If you are interested, I can provide you with login details.
      It is reproducible with any JDK6 - either 1.6.0, 1.6.0_04, 1.6.0_10 - and not reproducible with the latest JDK5 updates.
      It is always reproducible with the GTK L&F but not reproducible with the Metal L&F and Nimbus L&F (jdk6u10).

      I`ve tried to change ProgressBar.(foreground|background|selectionBackground|selectionForeground) properties of the UIManager - it works fine with Metal L&F and has no effect at all with GTK L&F.

      The test class is the following:
      package progressbarcheck;

      import java.awt.BorderLayout;
      import java.awt.Color;
      import java.awt.Container;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.swing.JFrame;
      import javax.swing.JProgressBar;
      import javax.swing.UIManager;
      import javax.swing.UnsupportedLookAndFeelException;
      import javax.swing.plaf.ColorUIResource;

      public class Main {

          public static void main(String args[]) {

              String[] lafs = {"javax.swing.plaf.metal.MetalLookAndFeel",
              "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"};
              for (String laf : lafs) {
                  try {
                      UIManager.getInstalledLookAndFeels();
                      UIManager.setLookAndFeel(laf);
                      UIManager.getDefaults().put("ProgressBar.foreground", new ColorUIResource(255,0,0));
                      UIManager.getDefaults().put("ProgressBar.background", new ColorUIResource(0,255,0));
                      UIManager.getDefaults().put("ProgressBar.selectionBackground", new ColorUIResource(0,0,255));
                      UIManager.getDefaults().put("ProgressBar.selectionForeground", new ColorUIResource(0,255,255));
                      
                      JProgressBar bar = new JProgressBar();
                      bar.setRequestFocusEnabled(false);
                      bar.setStringPainted(true);
                      JFrame theFrame = new JFrame("ProgressBar");

                      Container contentPane = theFrame.getContentPane();
                      contentPane.add(bar, BorderLayout.SOUTH);
                      theFrame.setSize(300, 60);
                      theFrame.setLocation(600, 400);
                      theFrame.setVisible(true);
                      for (int i = 0; i <= 100; i++) {
                          bar.setValue(i);
                          try {
                              Thread.sleep(20);
                          } catch (InterruptedException ex) {
                              Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                          }
                      }
                      theFrame.setVisible(false);
                  } catch (ClassNotFoundException ex) {
                  } catch (InstantiationException ex) {
                  } catch (IllegalAccessException ex) {
                  } catch (UnsupportedLookAndFeelException ex) {
                  }
              }
              System.exit(0);
          }
      }

            peterz Peter Zhelezniakov
            dlipin Dmitry Lipin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: