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

JProgressBar granularity > = 1%

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux dhcppc3 2.6.3-7mdk #1 Wed Mar 17 15:56:42 CET 2004 i686 unknown unknown GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When I use setValue on a JProgressBar, the value the progressbar doesn't update until the new value is at least 1 percent bigger than the old one. This causes the progressbar to move very abruptly on slow processes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      // ProgressBarExample.java
      // A demonstration of the JProgressBar component. The component tracks the
      // progress of a for loop.
      //
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class ProgressBarExample extends JPanel {

        JProgressBar pbar;
        static final int MY_MINIMUM=0;
        static final int MY_MAXIMUM=1000;

        public ProgressBarExample() {
           pbar = new JProgressBar();
           pbar.setMinimum(MY_MINIMUM);
           pbar.setMaximum(MY_MAXIMUM);
           add(pbar);
        }

        public void updateBar(int newValue) {
          pbar.setValue(newValue);
        }

        public static void main(String args[]) {

           final ProgressBarExample it = new ProgressBarExample();

           JFrame frame = new JFrame("Progress Bar Example");
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setContentPane(it);
           frame.pack();
           frame.setVisible(true);

           for (int i = MY_MINIMUM; i <= MY_MAXIMUM; i++) {
             final int percent=i;
             try {
               SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                     it.updateBar(percent);
                   }
               });
               java.lang.Thread.sleep(100);
             } catch (InterruptedException e) {;}
           }
        }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The progress bar should update every 1 step.
      ACTUAL -
      The progressbar only updates every 10 step.

      REPRODUCIBILITY :
      This bug can be reproduced always.
      ###@###.### 2004-12-13 20:47:48 GMT

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: