javax.swing.ProgressMonitor类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中javax.swing.ProgressMonitor类的一些代码示例,展示了ProgressMonitor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProgressMonitor类的具体详情如下:
包路径:javax.swing.ProgressMonitor
类名称:ProgressMonitor

ProgressMonitor介绍

暂无

代码示例

代码示例来源:origin: dermotte/LIRE

pm.setProgress(5);
pm.setNote("Starting clustering");
pm.setProgress(8);
pm.setNote("Step 1 finished");
pm.setProgress(11);
pm.setNote("Step 2 finished");
newStress = k.clusteringStep();
if (pm != null) { // set to XX of 100 after second step.
  pm.setProgress(cStep * 3 + 5);
  pm.setNote("Step " + cStep + " finished");

代码示例来源:origin: skylot/jadx

private void saveAll(boolean export) {
  JFileChooser fileChooser = new JFileChooser();
  fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fileChooser.setToolTipText(NLS.str("file.save_all_msg"));
  String currentDirectory = settings.getLastSaveFilePath();
  if (!currentDirectory.isEmpty()) {
    fileChooser.setCurrentDirectory(new File(currentDirectory));
  }
  int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select"));
  if (ret == JFileChooser.APPROVE_OPTION) {
    JadxArgs decompilerArgs = wrapper.getArgs();
    decompilerArgs.setExportAsGradleProject(export);
    if (export) {
      decompilerArgs.setSkipSources(false);
      decompilerArgs.setSkipResources(false);
    } else {
      decompilerArgs.setSkipSources(settings.isSkipSources());
      decompilerArgs.setSkipResources(settings.isSkipResources());
    }
    settings.setLastSaveFilePath(fileChooser.getCurrentDirectory().getPath());
    ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, NLS.str("msg.saving_sources"), "", 0, 100);
    progressMonitor.setMillisToPopup(0);
    wrapper.saveAll(fileChooser.getSelectedFile(), progressMonitor);
  }
}

代码示例来源:origin: skylot/jadx

@Override
  public void run() {
    try {
      decompiler.getArgs().setRootDir(dir);
      ThreadPoolExecutor ex = (ThreadPoolExecutor) decompiler.getSaveExecutor();
      ex.shutdown();
      while (ex.isTerminating()) {
        long total = ex.getTaskCount();
        long done = ex.getCompletedTaskCount();
        progressMonitor.setProgress((int) (done * 100.0 / (double) total));
        Thread.sleep(500);
      }
      progressMonitor.close();
      LOG.info("decompilation complete, freeing memory ...");
      decompiler.getClasses().forEach(JavaClass::unload);
      LOG.info("done");
    } catch (InterruptedException e) {
      LOG.error("Save interrupted", e);
      Thread.currentThread().interrupt();
    }
  }
};

代码示例来源:origin: protegeproject/protege

private void adjustProgress(String taskDescription, int taskCount) {
  if (monitor.isCanceled()) {
    throw new ExportCancelledException();
  }
  monitor.setNote(taskDescription);
  monitor.setProgress(taskCount);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

progressMonitor = new ProgressMonitor(
progressMonitor.setMillisToPopup(0);
progressMonitor.setMillisToDecideToPopup(0);
if (progress != -1) {
  progressMonitor.setProgress(progress);
} else {
  progressMonitor.setProgress(progress);
  progressMonitor.setNote(note);

代码示例来源:origin: cytoscape.coreplugins/rfilters

public void run() {
    if (pm.isCanceled()) {
      applyFilterCanceled = true;
      pm.close();
    } else {
      dCount = ((double) progressCount / (double) pm.getMaximum());
      progressNote = ((int) (dCount * 100.0) + "% complete");
      pm.setProgress(progressCount);
      pm.setNote(progressNote);
    }
  }
};

代码示例来源:origin: cflint/CFLint

@Override
public void startedProcessing(final String srcidentifier) {
  if (progressMonitor.isCanceled()) {
    throw new RuntimeException("Cancelled by user");
  }
  if (indeterminate && fileCounter + 1 >= totalFileCount) {
    totalFileCount += 10;
    progressMonitor.setMaximum(totalFileCount);
  }
  progressMonitor.setProgress(fileCounter++);
  progressMonitor.setNote("[" + fileCounter + "/" + totalFileCount + "] processing " + shorten(srcidentifier));
}

代码示例来源:origin: org.apache.uima/uimaj-tools

progressMonitor = new ProgressMonitor(DocumentAnalyzer.this, progressMsg, "", 0, numDocs + 2);
String initial = "Initializing.... Please wait ";
progressMonitor.setNote(initial);
progressMonitor.setMillisToPopup(-1);
progressMonitor.setMillisToDecideToPopup(-1);
numDocsProcessed = 0;
progressTimer.start();
aggDesc.getAnalysisEngineMetaData().getOperationalProperties().setMultipleDeploymentAllowed(
    false);            
progressMonitor.setProgress(1);
mCPM.setAnalysisEngine(ae);
progressMonitor.setProgress(2);
if (progressMonitor.isCanceled()) {
 mCPM.stop();
 progressMonitor.close();

代码示例来源:origin: com.github.ansell.pellet/pellet-common

protected void resetProgress() {
  super.resetProgress();
  monitor = new javax.swing.ProgressMonitor( null, progressTitle, progressMessage, 0,
      progressLength );
  monitor.setProgress( progress );
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

/**
 * Constructor.
 *
 * @param parent The parent component.
 */
public DefaultFilePasteCallback(Component parent) {
  monitor = new ProgressMonitor(parent,
      MSG.getString("Dialog.ProgressMonitor.Title"), "", 0, 1);
}

代码示例来源:origin: LibraryOfCongress/bagger

@Override
public synchronized void reportProgress(String activity, Object item, Long count, Long total) {
 if (count == null || total == null) {
  log.error("reportProgress received null info: count={}, total={}", count, total);
 }
 else {
  if (activityMonitored == null || activityMonitored.equals(activity)) {
   String message = MessageFormat.format("{0} ({2} of {3}) {1} ", activity, item, count, total);
   this.progressMonitor.setNote(message);
   this.progressMonitor.setMaximum(total.intValue());
   this.progressMonitor.setProgress(count.intValue());
  }
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

@Override
 public void done() {
  m_progress.close();
  if (m_error != null) {
   displayErrorDialog("There was a problem establishing the package\n"
    + "meta data cache. We'll try to use the repository" + "directly.",
    m_error);
  }
 }
}

代码示例来源:origin: org.vesalainen.dsql/dsql

@Override
protected Void doInBackground() throws Exception
{
  ProgressMonitor mon = new ProgressMonitor(frame, I18n.get("WAIT"), "", 0, 100);
  mon.setNote("");
  statement.getEngine().createProgressMonitor(mon);
  fetchResult = statement.execute();
  mon.close();
  return null;
}

代码示例来源:origin: MarginallyClever/Makelangelo-software

/**
 * Load and convert the image in the chosen style
 * @return false if loading cancelled or failed.
 */
@Override
public boolean load(InputStream in,MakelangeloRobot robot) {
  try {
    img = new TransformedImage( ImageIO.read(in) );
  } catch (IOException e1) {
    e1.printStackTrace();
    return false;
  }
  
  chosenRobot = robot;
  switch(getPreferredFillStyle()) {
    case 0:  scaleToFillPaper();  break;
    case 1:  scaleToFitPaper();  break;
    default: break;
  }
  
  pm = new ProgressMonitor(null, Translator.get("Converting"), "", 0, 100);
  pm.setProgress(0);
  pm.setMillisToPopup(0);
  
  chooseImageConversionOptions(robot);
  
  return true;
}

代码示例来源:origin: cytoscape.coreplugins/rfilters

progressNote = "";
final ProgressMonitor pm = new ProgressMonitor(frame, progressTitle, progressNote, 0, 100);
pm.setMillisToDecideToPopup(500);
pm.setMillisToPopup(2000);

代码示例来源:origin: igvteam/igv

public static void main(String[] args) throws MalformedURLException {
  URL url = HttpUtils.createURL(args[0]);
  String localFile = args[1];
  JComponent frame = null;
  String message = "Downloading " + url.toString();
  int min = 0;
  int max = 100;
  final javax.swing.ProgressMonitor monitor = new javax.swing.ProgressMonitor(frame, message, "", min, max);
  monitor.setMillisToDecideToPopup(100);
  Downloader dl = new Downloader(url, new File(localFile), monitor);
  (new Thread(dl)).start();
}

代码示例来源:origin: org.apache.uima/uimaj-tools

/**
 * Check progress monitor.
 */
private void checkProgressMonitor() {
 // if user has clicked cancel, abort
 if (progressMonitor.isCanceled()) {
  progressMonitor.setNote("Cancelling...");
  mCPM.stop();
  aborted();
 }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

boolean isProgressCancelled() {
  if (progressMonitor == null) {
    return false;
  } else {
    return progressMonitor.isCanceled();
  }
}

代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet

private static boolean checkSHA256(File provingKey, Component parent) throws IOException {
    MessageDigest sha256;
    try {
      sha256 = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException impossible) {
      throw new IOException(impossible);
    }
    try (InputStream is = new BufferedInputStream(new FileInputStream(provingKey))) {
      ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(parent, LOCAL_MSG_VERIFYING_PROVING_KEY, is);
      pmis.getProgressMonitor().setMaximum(PROVING_KEY_SIZE);
      pmis.getProgressMonitor().setMillisToPopup(10);
      DigestInputStream dis = new DigestInputStream(pmis, sha256);
      byte[] temp = new byte[0x1 << 13];
      while (dis.read(temp) >= 0) ;
      byte[] digest = sha256.digest();
      return PROVING_KEY_SHA256.equalsIgnoreCase(DatatypeConverter.printHexBinary(digest));
    }
  }
}

代码示例来源:origin: Slowpoke101/FTBLaunch

Logger.logInfo("Checking/Downloading " + assets.size() + " assets, this may take a while...");
final ProgressMonitor prog = new ProgressMonitor(LaunchFrame.getInstance(), "Downloading Files...", "", 0, 100);
prog.setMaximum(assets.size() * 100);

相关文章