long expected = ( now - timestamp ) * ( max - min ) / ( progress - min );
long expected = ( progress - min == 0 ) ? ( now - timestamp ) * ( max - min ) : ( now - timestamp ) * ( max - min ) / ( progress - min );
    public void actionPerformed(ActionEvent ae)    {       long now = System.currentTimeMillis();       if ( first )       {         if (( now - timestamp ) > millisToDecideToPopup )         {           first = false;           long expected = ( now - timestamp ) * ( max - min ) / ( progress - min );           if ( expected > millisToPopup )           {             createDialog();           }         }         else         {           // We have not waited long enough to make a decision,           // so return and try again when the timer is invoked.           return;         }       }       else if ( progressDialog != null )       {         // The progress dialog is being displayed. We now calculate         // whether setting the progress bar to the current progress         // value would result in a visual difference.          int delta = progress - progressBar.getValue();         if ( ( delta * progressBar.getWidth() / (max - min) ) > 0 )         {           // At least one pixel would change.           progressBar.setValue(progress);         }       }       else       {         // No dialog necessary         timer.stop();         timer = null;       }      timestamp = now;    }