title: JProgressBar will not update until process is completed
body: <p>Tons of <code>JProgressBar</code> questions on here I know, but through all the answers and I can't seem to diagnose my issue. I am processing a file with some address verification software. I click the Process button and I need my <code>JProgressBar</code> to update with each file processed.
  Here is the button:</p>
  
  <pre><code>private JButton getJButton0() {
  ...
     jButton0.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
           jButton0ActionActionPerformed(event);
           t.start();
        }
  ...
  </code></pre>
  
  <p>Per everybody's recommendation, I used the <code>setValue()</code> method within a thread</p>
  
  <pre><code>Thread t = new Thread(){
      public void run() {
      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
          jProgressBar0.setValue(BulkProcessor.getPercentComplete());
      }
  });
  try {
      Thread.sleep(100);
  } catch (InterruptedException e) {
  }
  ...
  </code></pre>
  
  <p><code>BulkProcessor.getPercentComplete()</code> is a method I'm calling from another class which represents the percentage complete. I have tested this method and it updates correctly. The issue is that the progress bar will not update until the files are finished processing, and then it will jump to 100%. I apologize if this is a repeat question, but I have done some serious digging on this site with no luck. Any help much appreciated. </p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>Per recommended duplicate, I tried this:</p>
  
  <pre><code>public void update(){
     new SwingWorker&lt;Void,Void&gt;() {
     protected Void doInBackground() throws Exception {
     jProgressBar0.setValue(BulkProcessor.getPercentComplete());
     return null;
   };
   }.execute();
  }
  </code></pre>
  
  <p>And then tried calling this update() method under the <code>actionPerformed()</code> (switched <code>t.start()</code> with <code>update()</code>). I am still having the same issue.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Based on user1676075's recommendation, however same issue:</p>
  
  <pre><code>    public static void update(){
         new SwingWorker&lt;Void,Integer&gt;() {
         protected Void doInBackground() throws Exception {
             do
             {
             percentComplete = BulkProcessor.getPercentComplete();
             publish(percentComplete);
             Thread.sleep(100);
             } while(percentComplete &lt; 100);
  
          return null;
         }
         @Override
      protected
         void process(List&lt;Integer&gt; progress)
         {
             jProgressBar0.setValue(progress.get(0));
         }
       }.execute();
     }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is the code from my <code>BulkProcessor</code> class</p>
  
  <pre><code> private String getOutputLine( String searchString, String inputLine )
  throws QasException
  {
   ..(code for processing lines)..
   countRecord++;
      percentComplete = (int) Math.round((countRecord/totalRecord)*100);
  </code></pre>
  
  <p><code>totalRecord</code> is updated in the main class of my <code>BulkProcessor</code> class</p>
  
  <pre><code> public static void main( String input, String output ){
      count.clear();
      try{
          String inputFile = input;
          String outputFile = output;
          LineNumberReader  lnr = new LineNumberReader(new FileReader(new File(input)));
          lnr.skip(Long.MAX_VALUE);
          totalRecord = lnr.getLineNumber() + 1; //line count in file
          BulkProcessor bulk = new BulkProcessor(inputFile, outputFile, ConfigManager.DFLT_NAME);
          bulk.process();
      }catch(Exception e ){
          e.printStackTrace();
      }
  
  }
  </code></pre>