本文整理汇总了Java中javax.swing.ProgressMonitor.setProgress方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitor.setProgress方法的具体用法?Java ProgressMonitor.setProgress怎么用?Java ProgressMonitor.setProgress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ProgressMonitor
的用法示例。
在下文中一共展示了ProgressMonitor.setProgress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFrames
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/** Add all the frames from an AnimationReader.
*
* @param r the animation to read.
* @param monitor an optional ProgressMonitor to update
* @throws IOException if an error occurs copying frames.
*/
public void addFrames(AnimationReader r, ProgressMonitor monitor) throws IOException {
if(monitor!=null)
monitor.setMaximum(r.getFrameCount());
BufferedImage bi = r.getNextFrame(false);
int ctr = 1;
while(bi!=null) {
if(monitor!=null) {
if(monitor.isCanceled()) {
throw new UserCancelledException();
}
monitor.setProgress(ctr);
}
float d;
try {
d = (float)r.getFrameDuration();
} catch(Exception e) {
e.printStackTrace();
d = 1;
}
addFrame(d, bi, .98f);
bi = r.getNextFrame(false);
ctr++;
}
}
示例2: actionPerformed
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/**
* Invoked when the user presses the start button.
*/
public void actionPerformed(ActionEvent evt) {
progressMonitor = new ProgressMonitor(
FileTransferProgressMonitorDemo.this, "Uploads a file...", "",
0, 100);
progressMonitor.setProgress(0);
Thread t = new Thread() {
public void run() {
doFileUpload();
}
};
t.start();
task = new Task();
task.addPropertyChangeListener(this);
task.execute();
startButton.setEnabled(false);
}
示例3: actionPerformed
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
/**
* Invoked when the user presses the start button.
*/
public void actionPerformed(ActionEvent evt) {
progressMonitor = new ProgressMonitor(
FileTransferProgressMonitorDownloadDemo.this,
"Downloads a file...", "", 0, 100);
progressMonitor.setProgress(0);
Thread t = new Thread() {
public void run() {
doFileDownload();
}
};
t.start();
task = new Task();
task.addPropertyChangeListener(this);
task.execute();
startButton.setEnabled(false);
}
示例4: RanksResult
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public RanksResult(JFrame parent,Ranks ranks,int bestNRanks,boolean ascendant){
super(parent,true);
//this.parent=parent;
this.bestNRanks=bestNRanks;
this.ranks=ranks;
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.factorCompare=ascendant?-1:1;
this.maxJump=ranks.getMaxJump();
this.stackWidth=ranks.getStackWidth();
progressMonitor=new ProgressMonitor(parent,AIRanksTool.getUIText("Result_Progress_Message"),"",0,100);
progressMonitor.setProgress(0);
task = new Task();
task.addPropertyChangeListener(this);
task.execute();
}
示例5: doInBackground
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
@Override
public Void doInBackground() {
String rawString = configManager.getRawString();
try {
stream = new ProgressMonitorInputStream(null, (Object) "Flashing",
new ByteArrayInputStream(rawString
.getBytes(HacklaceConfigManager.HACKLACE_CHARSET)));
ProgressMonitor progressMonitor = stream.getProgressMonitor();
progressMonitor.setMaximum(rawString.length());
progressMonitor.setProgress(0);
progressMonitor.setMillisToPopup(0);
animatorGui.setCursor(Cursor
.getPredefinedCursor(Cursor.WAIT_CURSOR));
flashExporter.write(stream);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Error flashing hacklace: "
+ ex, "Error", JOptionPane.ERROR_MESSAGE);
}
return null;
}
示例6: init
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public void init(int op, String src, String dest, long max) {
this.max = max;
monitor = new ProgressMonitor(null,
((op == SftpProgressMonitor.PUT)
? "put" : "get") + ": " + src,
"", 0, (int) max);
count = 0;
percent = -1;
monitor.setProgress((int) this.count);
monitor.setMillisToDecideToPopup(1000);
}
示例7: actionPerformed
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
String path = pathField.getText();
if (path.trim().isEmpty()) {
JOptionPane.showMessageDialog(this, "A file path must be selected.", "Empty File Path", JOptionPane.ERROR_MESSAGE);
return;
}
File selectedFile = new File(path);
if (selectedFile.exists()) {
this.setVisible(false);
int option = JOptionPane.showConfirmDialog(cliGuiCtx.getMainWindow(), "Overwrite " + path, "Overwrite?", JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.NO_OPTION) {
this.setVisible(true);
return;
}
}
this.dispose();
progressMonitor = new ProgressMonitor(cliGuiCtx.getMainWindow(), "Downloading " + fileName, "", 0, 100);
progressMonitor.setProgress(0);
downloadTask = new DownloadLogTask(selectedFile);
downloadTask.addPropertyChangeListener(this);
downloadTask.execute();
}
示例8: createBackup
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public void createBackup(Component c, String name, CCDate date, boolean persistent, String jccversion, String dbversion) {
if (CCProperties.getInstance().ARG_READONLY) {
CCLog.addInformation(LocaleBundle.getString("LogMessage.OperationFailedDueToReadOnly")); //$NON-NLS-1$
return;
}
CCLog.addInformation(LocaleBundle.getString("LogMessage.BackupStarted")); //$NON-NLS-1$
ProgressMonitor monitor = DialogHelper.getLocalPersistentProgressMonitor(c, "MainFrame.backupRunning"); //$NON-NLS-1$
try {
createBackupInternal(name, date, persistent, jccversion, dbversion, new ProgressCallbackProgressMonitorHelper(monitor), false);
} catch (IOException e) {
CCLog.addError(e);
monitor.setProgress(monitor.getMaximum());
monitor.close();
return;
}
monitor.setProgress(monitor.getMaximum());
monitor.close();
CCLog.addInformation(LocaleBundle.getString("LogMessage.BackupCreated")); //$NON-NLS-1$
CCProperties.getInstance().PROP_BACKUP_LASTBACKUP.setValue(CCDate.getCurrentDate());
}
示例9: export
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public boolean export(OutputStream out)
throws IOException, NoninvertibleTransformException {
this.out = out;
List lines = ornament.getLines();
int nLines = lines.size(), maxProgress = nLines + 2;
ProgressMonitor pm = new ProgressMonitor(ornament, I18n._("exporting"),
null, 0, maxProgress);
init();
prepareStream();
pm.setProgress(1);
head();
BufferedImage bg = ornament.getBackgroundTile();
if (bg != null) background(bg);
for (int i = 0; i != nLines && !pm.isCanceled(); ++i) {
pm.setProgress(2+i);
export((LinPath)lines.get(i));
}
pm.setProgress(2+nLines);
postBody();
tail();
if (out != null) out.close();
pm.close();
return true;
}
示例10: construct
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
@Override
public Object construct() {
ProgressMonitor pm = new ProgressMonitor(own, msg, "", 0, max);
pm.setMillisToDecideToPopup(0);
pm.setMillisToPopup(0);
pm.setProgress(0);
return pm;
}
示例11: SkelGen
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public SkelGen( List<Line> footprint, Tweed tweed, BlockGen blockGen ) {
super( "model", tweed );
this.footprint = footprint;
this.blockGen = blockGen;
skelFootprint = new SkelFootprint(tweed);
ProgressMonitor m = new ProgressMonitor( tweed.frame(), "Optimizing", "", 0, 100 );
m.setProgress( 1 );
m.setMillisToPopup( 0 );
new Thread( () -> {
optimize(m);
SkelGen.this.calculateOnJmeThread(); } ).start();
}
示例12: runAnnotation
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
private boolean runAnnotation() {
theThread.start();
// launch progress dialog
progressDialog = new ProgressMonitor(theApplication, "Matching peaks with fragments", null, 0, theThread.getTarget());
// set up the timer action
activityMonitor = new Timer(200, new ActionListener() {
public void actionPerformed (ActionEvent event) {
int progress = theThread.getProgress();
// show progress
progressDialog.setProgress(progress);
// check if task is completed or canceled
if( progress==theThread.getTarget() || theThread.isInterrupted() || progressDialog.isCanceled ()) {
activityMonitor.stop();
progressDialog.close();
if( progress!=theThread.getTarget() ) {
theThread.interrupt();
onAnnotationAborted(theThread);
}
else {
onAnnotationCompleted(theThread);
}
}
}
});
activityMonitor.start();
// return control
return true;
}
示例13: scanAnnotationCascade
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public boolean scanAnnotationCascade(boolean ask, Vector<Scan> parentScans) {
if(setAnnotationOptions(ask)){
theApplication.haltInteractions();
showTopResults = false;
scanThread=new ScanAnnotationCascadeThread(parentScans,theWorkspace.getFragmentOptions(), theWorkspace.getAnnotationOptions());
scanThread.start();
progressDialog = new ProgressMonitor(theApplication,"Parent scans completed", null, 0, scanThread.getTarget());
// set up the timer action
activityMonitor = new Timer(200, new ActionListener() {
public void actionPerformed(ActionEvent event) {
int progress = scanThread.getProgress();
// show progress
progressDialog.setProgress(progress);
// check if task is completed or canceled
if (progress == scanThread.getTarget()
|| progressDialog.isCanceled()) {
System.err.println("Stopping activity monitor");
activityMonitor.stop();
progressDialog.close();
if (progress != scanThread.getTarget()) {
scanThread.interrupt();
onAnnotationAborted(scanThread);
} else {
onAnnotationCompleted(scanThread);
}
}
}
});
activityMonitor.start();
}
return true;
}
示例14: actionPerformed
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Create Parallel Coordinates Chart")) {
// log("Create: discrete level count of last parameter is: "+mainWindow.getDataSheet().getParameter(mainWindow.getDataSheet().getParameterCount()-1).getDiscreteLevelCount());
if (mainWindow.getDataSheet() == null) {
JOptionPane.showMessageDialog(mainWindow, "Please create a data sheet first by selecting Data->Import.", "Create Chart", JOptionPane.INFORMATION_MESSAGE);
} else {
ProgressMonitor progressMonitor = new ProgressMonitor(mainWindow, "", "Building Chart...", 0, 100);
progressMonitor.setProgress(0);
ParallelCoordinatesChartCreationThread sw = new ParallelCoordinatesChartCreationThread(mainWindow, progressMonitor);
sw.execute();
}
}
else if (e.getActionCommand().equals("Create Scatter Chart 2D")) {
if (mainWindow.getDataSheet() == null) {
JOptionPane.showMessageDialog(mainWindow, "Please create a data sheet first by selecting Data->Import.", "Create Chart", JOptionPane.INFORMATION_MESSAGE);
} else {
ScatterChart2D chart = new ScatterChart2D(mainWindow.getDataSheet(), true, new Dimension(600, 600), mainWindow.getUniqueChartId(ScatterChart2D.class));
try {
new ChartFrame(mainWindow, chart);
this.mainWindow.getCurrentSession().addChart(chart);
} catch (NoParametersDefinedException e1) {
JOptionPane.showMessageDialog(mainWindow, "Cannot create chart when no parameters are defined.", "No parameters defined!", JOptionPane.ERROR_MESSAGE);
}
}
} else {
System.out.println(e.getActionCommand());
}
}
示例15: updateAnswers
import javax.swing.ProgressMonitor; //导入方法依赖的package包/类
public void updateAnswers() {
final int questionCount = questions.size();
if (questionCount == 0) {
showMessage(JOptionPane.INFORMATION_MESSAGE, NO_QUESTIONS_MESSAGE);
return;
}
try {
if (! mngr.getReasoner().isClassified()) {
showMessage(JOptionPane.WARNING_MESSAGE, NSYNC_MESSAGE);
}
} catch (OWLReasonerException e) {
showMessage(JOptionPane.ERROR_MESSAGE, e.getMessage());
return;
}
progressMonitor = new ProgressMonitor(parent, "Updating answers to " + questionCount + " questions...", "", 0, questionCount);
progressMonitor.setProgress(0);
task = new Task();
task.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if ("progress" == evt.getPropertyName()) {
int progress = (Integer) evt.getNewValue();
progressMonitor.setProgress(progress);
String message = String.format("Completed %d of %d.\n", progress, questionCount);
progressMonitor.setNote(message);
if (progressMonitor.isCanceled()) {
task.cancel(true);
logger.info("Task cancelled");
}
}
}
});
task.execute();
}