コード例 #1
0
 // 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();
     }
   }
 }
コード例 #2
0
 public void start() {
   // task.execute();
   if (indeterminate) {
     progressMonitor.setIndeterminate(true);
   }
   SwingWorkerExecutor.getInstance().execute(task);
 }
コード例 #3
0
 public MonitoredTask(SwingWorker task, String msg, Component parentComponent) {
   this.task = task;
   // create the progress monitor
   progressMonitor = new ModalProgressMonitor(parentComponent, msg, "", 0, 100);
   progressMonitor.setProgress(0);
   // add ProgressMonitorExample as a listener on CopyFiles;
   // of specific interest is the bound property progress
   task.addPropertyChangeListener(this);
 }