JProgressBar: Why my JProgressBar finished instantly?
<p>So, let's assume that I have one JProgressBar called <code>pbProgress</code>, and a button called <code>btnFill</code>.</p>

<p>The code is simple:</p>

<pre><code> private void btnFillActionPerformed(java.awt.event.ActionEvent evt) {                                        
    int i = 0;

    while(i &lt;= 100){
        pbProgress.setValue(i);
        i++;

        try{
            Thread.sleep(100);
        }
        catch(Exception e){
            System.err.println("Error" + e);
        }
    }
}                                      
</code></pre>

<p>With or without the <code>try catch</code> it keep finished instantly (well, I'm pretty sure that's not the problem). Can someone solve this? Or am I doing some silly mistake? Thanks for the answers!
Note: this code is actually copied from a youtube video, but in that video the progress bar works properly from 0% to 100% and not instant.</p>