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

Indeterminate mode of JProgressBar in ProgressMonitor

XMLWordPrintable

      Name: rmT116609 Date: 08/18/2004


      A DESCRIPTION OF THE REQUEST :
      I beleive that the javax.swing.ProgressMonitor should be able to have the "setIndeterminate(boolean)" feature of the JProgressBar.

      JUSTIFICATION :
      I am creating a program which uses the GZIP commpression streams and I am unable to detirmine the resulting file size when inflating the commpressed file.

      Thus, I am unable to use the ProgressMonitor in this case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      After setIndeterminate(true) is called, the ProgressMonitor could display after the first millisToDecideToPopup regardless of the progress made, and stay open untill ProgressMonitor.close() is called.
      ACTUAL -
      The ProgressMonitor simply assumes that when I have passed the preset maximum progress that my program has finished. In most cases this is fine. However since I do not actually know the max progress the ProgressMonitor closes itself and my program continues to work in the background.

      ---------- BEGIN SOURCE ----------
      GZIPInputStream in = new GZIPInputStream(new FileInputStream(new File("file.txt")));

      ProgressMonitor progress = new ProgressMonitor(null, "", "", 0, new File("file.txt").length());

      byte[] buf = new byte[1000];
      int length = -1;
      int progressInt = 0;

      while((length = in.read(buf)) != -1) {

      progress.setProgress(progressInt += length);

      }

      progress.close();
      //PROGRESS MONITOR SHUTS DOWN BEFORE THE COMPLETE STREAM HAS BEEN READ.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      File file = new File("file.txt");
      GZIPInputStream in = new GZIPInputStream(new FileInputStream(file));

      ProgressMonitor progress = new ProgressMonitor(null, "", "", 0, file.length());

      byte[] buf = new byte[1000];
      int length = -1;
      int progressInt = 0;

      while((length = in.read(buf)) != -1) {

      progress.setProgress((progressInt += length) % file.length());

      }

      progress.close();


      (Incident Review ID: 297480)
      ======================================================================

            shickeysunw Shannon Hickey (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: