title: java applet: JProgressBar updating/refreshing only at completion
body: <p>I'm just trying to iterate in for loop and updating values of <code>JProgressBar</code> inside the loop, initiating <code>SwingUtilities.invokeLater</code>.. but it's only updating after completion. 
  Below is my simple code:</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Rectangle;
  import javax.swing.JApplet;
  import javax.swing.JButton;
  import javax.swing.JPanel;
  import javax.swing.JProgressBar;
  import javax.swing.SwingUtilities;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class ProgressBar extends JApplet {
      JProgressBar pg = null;
      JPanel panel = null;
      JButton start = null;
      int i;
  
      public void init() {
          pg = new JProgressBar(0, 100);
          pg.setStringPainted(true);
          this.setSize(1200, 600);
          this.setLayout(null);
          panel = new JPanel();
          panel.setLayout(null);
          panel.setBackground(Color.white);
          this.setContentPane(panel);
          this.setVisible(true);
          pg.setBounds(new Rectangle(630, 20, 150, 30));
          add(pg);
  
  
          start = new JButton("start");
          start.setBounds(new Rectangle(330, 20, 200, 30));
          start.setBackground(Color.lightGray);
          panel.add(start);
  
          start.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  pg.setValue(0);
                  pg.setStringPainted(true);
  
                  for (i = 0; i &lt;= 100; i = i + 1) {
                      SwingUtilities.invokeLater(new Runnable() {
                          public void run() {
                              try {
                                  pg.setValue(i);
                                  java.lang.Thread.sleep(100);
                              } catch (Exception e) {}
                          }
                      });
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>How to reflect the updation of <code>progress bar</code> in incrementing way as it's updating only <strong>100%</strong> after for loop completion.</p>