public class ProgressMonitor
extends java.lang.Object
Example: AddDatasetTask task = new AddDatasetTask(datasets); ProgressMonitor pm = new ProgressMonitor(task); pm.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("success")) { doGoodStuff(); } } }); pm.start( this, "Add Datasets", datasets.size()); class AddDatasetTask extends ProgressMonitorTask { private List datasets; OpenDatasetTask(List datasets) { this.datasets = datasets; } public void run() { Iterator iter = datasets.iterator(); while (iter.hasNext()) { AddeDataset ads = (AddeDataset) iter.next(); this.note = ads.filenameReletive(); try { ads.addImageData( currentSM.serverInfo(), results, false); } catch (IOException ioe) { error = ioe.getMessage(); break; } if (cancel) break; this.progress++; } success = !cancel && !isError(); done = true; // do last! } }
ProgressMonitorTask
Constructor and Description |
---|
ProgressMonitor(ProgressMonitorTask task) |
ProgressMonitor(ProgressMonitorTask task,
int millisToPopup,
int millisToDecideToPopup) |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Add listener: action event sent when task is done.
|
ProgressMonitorTask |
getTask() |
void |
removeActionListener(java.awt.event.ActionListener l)
Remove listener
|
void |
start(java.awt.Component top,
java.lang.String taskName,
int progressMaxCount)
Call this from awt event thread.
|
public ProgressMonitor(ProgressMonitorTask task)
public ProgressMonitor(ProgressMonitorTask task, int millisToPopup, int millisToDecideToPopup)
public ProgressMonitorTask getTask()
public void addActionListener(java.awt.event.ActionListener l)
public void removeActionListener(java.awt.event.ActionListener l)
public void start(java.awt.Component top, java.lang.String taskName, int progressMaxCount)
top
- put ProgressMonitor on top of this component (may be null)taskName
- display name of taskprogressMaxCount
- maximum number of Progress indicator