com.asprise.util.ui.progress
Class ProgressDialog

java.lang.Object
  extended bycom.asprise.util.ui.progress.ProgressDialog
All Implemented Interfaces:
com.asprise.util.ui.progress.ProgressMonitorWithSubTask, com.asprise.util.ui.progress.TaskProgressMonitor

public class ProgressDialog
extends Object
implements com.asprise.util.ui.progress.ProgressMonitorWithSubTask

Represents a modal (or non-modal) dialog displaying the progress.

Asprise Progress Monitor Dialog is an improved implementation of Sun's ProgressMonitor (javax.swing.ProgressMonitor). With all the features of Sun's ProgressMonitor, Asprise Progress Monitor Dialog offers the following additional features:

Sample code:

1.	import com.asprise.util.ui.progress.ProgressDialog;
2.	
3.	public class DemoSimple {
4.		public static void main(String[] args) throws InterruptedException {
5.			final int range = 10;		
6.			ProgressDialog progressDialog = new ProgressDialog(null, "Progress");
7.			progressDialog.beginTask("Number Counting", range, true);
8.			
9.			for(int i=0; i<range; i++) {
10.				if(progressDialog.isCanceled()) {
11.					System.out.println("CANCELED.");
12.					break;
13.				}
14.	
15.				System.out.println(i + " of " + range);
16.				progressDialog.worked(1); 
17.				Thread.sleep(500);
18.			}
19.			
20.			System.exit(0);
21.		}
22.	}
 

For more details, visit http://jack.asprise.net.

See Also:
ProgressMonitor

Field Summary
 boolean displayPercentageInProgressBar
          Displays the percentage in the center of the progress bar.
 boolean displayTimeLeft
          Displays the estimated remaining time.
 long millisToDecideToPopup
          the amount of time to wait before deciding whether or not to popup a progress monitor.
 long millisToPopup
          the amount of time it will take for the popup to appear.
 boolean modal
          Whether this dialog should be modal.
 Dimension preferedSize
          The preferened size for the dialog.
 boolean showAnimation
          Displays file copy animation.
 Component topComponent
          If desired, attach a component at the top of the dialog.
 
Fields inherited from interface com.asprise.util.ui.progress.TaskProgressMonitor
INDETERMINATE
 
Constructor Summary
ProgressDialog()
          Creates a default progress dialog.
ProgressDialog(Component parentComponent)
          Creates a progress dialog titled 'Progress'.
ProgressDialog(Component parentComponent, String title)
          Creates a progress dialog.
 
Method Summary
 void beginSubTask(String name, int totalWork)
           
 void beginTask(String name, int totalWork, boolean isCancelable)
           
static void execute(Runnable task, Component parentComponent)
          Executes the specified task in a separate thread with a progress dialog.
 void finished()
           
 boolean isCanceled()
           
 void setCanceled(boolean canceled)
           
 void setSubTaskName(String name)
           
 void setTaskName(String name)
           
 void subFinished()
           
 void subWorked(int worked)
           
 void worked(int worked)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

millisToDecideToPopup

public long millisToDecideToPopup
the amount of time to wait before deciding whether or not to popup a progress monitor.


millisToPopup

public long millisToPopup
the amount of time it will take for the popup to appear. (If the predicted time remaining is less than this time, the popup won't be displayed.)


displayPercentageInProgressBar

public boolean displayPercentageInProgressBar
Displays the percentage in the center of the progress bar.


displayTimeLeft

public boolean displayTimeLeft
Displays the estimated remaining time.


showAnimation

public boolean showAnimation
Displays file copy animation.


preferedSize

public Dimension preferedSize
The preferened size for the dialog.


modal

public boolean modal
Whether this dialog should be modal.


topComponent

public Component topComponent
If desired, attach a component at the top of the dialog.

Constructor Detail

ProgressDialog

public ProgressDialog()
Creates a default progress dialog.


ProgressDialog

public ProgressDialog(Component parentComponent)
Creates a progress dialog titled 'Progress'.

Parameters:
parentComponent - the component that this dialog is based on or null for console applications.

ProgressDialog

public ProgressDialog(Component parentComponent,
                      String title)
Creates a progress dialog.

Parameters:
parentComponent - the component that this dialog is based on or null for console applications.
title - the title of the dialog
Method Detail

execute

public static void execute(Runnable task,
                           Component parentComponent)
Executes the specified task in a separate thread with a progress dialog.

Parameters:
task - the task to be performed
parentComponent - UI component based on or null for console applications

beginTask

public void beginTask(String name,
                      int totalWork,
                      boolean isCancelable)
Specified by:
beginTask in interface com.asprise.util.ui.progress.TaskProgressMonitor

worked

public void worked(int worked)
Specified by:
worked in interface com.asprise.util.ui.progress.TaskProgressMonitor

setTaskName

public void setTaskName(String name)
Specified by:
setTaskName in interface com.asprise.util.ui.progress.TaskProgressMonitor

setCanceled

public void setCanceled(boolean canceled)
Specified by:
setCanceled in interface com.asprise.util.ui.progress.TaskProgressMonitor

isCanceled

public boolean isCanceled()
Specified by:
isCanceled in interface com.asprise.util.ui.progress.TaskProgressMonitor

finished

public void finished()
Specified by:
finished in interface com.asprise.util.ui.progress.TaskProgressMonitor

beginSubTask

public void beginSubTask(String name,
                         int totalWork)
Specified by:
beginSubTask in interface com.asprise.util.ui.progress.ProgressMonitorWithSubTask

subWorked

public void subWorked(int worked)
Specified by:
subWorked in interface com.asprise.util.ui.progress.ProgressMonitorWithSubTask

setSubTaskName

public void setSubTaskName(String name)
Specified by:
setSubTaskName in interface com.asprise.util.ui.progress.ProgressMonitorWithSubTask

subFinished

public void subFinished()
Specified by:
subFinished in interface com.asprise.util.ui.progress.ProgressMonitorWithSubTask


Copyright © 2005 Jack Li. All Rights Reserved.