// executes in event dispatch thread
 public void propertyChange(PropertyChangeEvent event) {
   // if the operation is finished or has been canceled by
   // the user, take appropriate action
   if (progressMonitor.isCanceled()) {
     task.cancel(true);
   } else if (event.getPropertyName().equals("progress")) {
     // get the % complete from the progress event
     // and set it on the progress monitor
     int progress = ((Integer) event.getNewValue()).intValue();
     progressMonitor.setProgress(progress);
     if (progress >= 100) {
       progressMonitor.close();
     }
   }
 }