javax.swing
Class ProgressMonitor

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.ProgressMonitor
All Implemented Interfaces:
Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible

public class ProgressMonitor
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible

A class to monitor the progress of some operation. If it looks like the operation will take a while, a progress dialog will be popped up. When the ProgressMonitor is created it is given a numeric range and a descriptive string. As the operation progresses, call the setProgress method to indicate how far along the [min,max] range the operation is. Initially, there is no ProgressDialog. After the first millisToDecideToPopup milliseconds (default 500) the progress monitor will predict how long the operation will take. If it is longer than millisToPopup (default 2000, 2 seconds) a ProgressDialog will be popped up.

From time to time, when the Dialog box is visible, the progress bar will be updated when setProgress is called. setProgress won't always update the progress bar, it will only be done if the amount of progress is visibly significant.

For further documentation and examples see How to Monitor Progress, a section in The Java Tutorial.

See Also:
ProgressMonitorInputStream sample code for javax.swing.ProgressMonitorInputStream definition code for javax.swing.ProgressMonitorInputStream

Nested Class Summary
protected  class ProgressMonitor.AccessibleProgressMonitor sample code for javax.swing.ProgressMonitor.AccessibleProgressMonitor definition code for javax.swing.ProgressMonitor.AccessibleProgressMonitor
          AccessibleProgressMonitor implements accessibility support for the ProgressMonitor class.
 
Field Summary
protected  AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext accessibleContext sample code for javax.swing.ProgressMonitor.accessibleContext definition code for javax.swing.ProgressMonitor.accessibleContext
           
 
Constructor Summary
ProgressMonitor sample code for javax.swing.ProgressMonitor.ProgressMonitor(java.awt.Component, java.lang.Object, java.lang.String, int, int) definition code for javax.swing.ProgressMonitor.ProgressMonitor(java.awt.Component, java.lang.Object, java.lang.String, int, int) (Component sample code for java.awt.Component definition code for java.awt.Component  parentComponent, Object sample code for java.lang.Object definition code for java.lang.Object  message, String sample code for java.lang.String definition code for java.lang.String  note, int min, int max)
          Constructs a graphic object that shows progress, typically by filling in a rectangular bar as the process nears completion.
 
Method Summary
 void close sample code for javax.swing.ProgressMonitor.close() definition code for javax.swing.ProgressMonitor.close() ()
          Indicate that the operation is complete.
 AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext getAccessibleContext sample code for javax.swing.ProgressMonitor.getAccessibleContext() definition code for javax.swing.ProgressMonitor.getAccessibleContext() ()
          Gets the AccessibleContext for the ProgressMonitor
 int getMaximum sample code for javax.swing.ProgressMonitor.getMaximum() definition code for javax.swing.ProgressMonitor.getMaximum() ()
          Returns the maximum value -- the higher end of the progress value.
 int getMillisToDecideToPopup sample code for javax.swing.ProgressMonitor.getMillisToDecideToPopup() definition code for javax.swing.ProgressMonitor.getMillisToDecideToPopup() ()
          Returns the amount of time this object waits before deciding whether or not to popup a progress monitor.
 int getMillisToPopup sample code for javax.swing.ProgressMonitor.getMillisToPopup() definition code for javax.swing.ProgressMonitor.getMillisToPopup() ()
          Returns the amount of time it will take for the popup to appear.
 int getMinimum sample code for javax.swing.ProgressMonitor.getMinimum() definition code for javax.swing.ProgressMonitor.getMinimum() ()
          Returns the minimum value -- the lower end of the progress value.
 String sample code for java.lang.String definition code for java.lang.String getNote sample code for javax.swing.ProgressMonitor.getNote() definition code for javax.swing.ProgressMonitor.getNote() ()
          Specifies the additional note that is displayed along with the progress message.
 boolean isCanceled sample code for javax.swing.ProgressMonitor.isCanceled() definition code for javax.swing.ProgressMonitor.isCanceled() ()
          Returns true if the user hits the Cancel button in the progress dialog.
 void setMaximum sample code for javax.swing.ProgressMonitor.setMaximum(int) definition code for javax.swing.ProgressMonitor.setMaximum(int) (int m)
          Specifies the maximum value.
 void setMillisToDecideToPopup sample code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int) (int millisToDecideToPopup)
          Specifies the amount of time to wait before deciding whether or not to popup a progress monitor.
 void setMillisToPopup sample code for javax.swing.ProgressMonitor.setMillisToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToPopup(int) (int millisToPopup)
          Specifies the amount of time it will take for the popup to appear.
 void setMinimum sample code for javax.swing.ProgressMonitor.setMinimum(int) definition code for javax.swing.ProgressMonitor.setMinimum(int) (int m)
          Specifies the minimum value.
 void setNote sample code for javax.swing.ProgressMonitor.setNote(java.lang.String) definition code for javax.swing.ProgressMonitor.setNote(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  note)
          Specifies the additional note that is displayed along with the progress message.
 void setProgress sample code for javax.swing.ProgressMonitor.setProgress(int) definition code for javax.swing.ProgressMonitor.setProgress(int) (int nv)
          Indicate the progress of the operation being monitored.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

accessibleContext sample code for javax.swing.ProgressMonitor.accessibleContext

protected AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext  accessibleContext
Constructor Detail

ProgressMonitor sample code for javax.swing.ProgressMonitor(java.awt.Component, java.lang.Object, java.lang.String, int, int) definition code for javax.swing.ProgressMonitor(java.awt.Component, java.lang.Object, java.lang.String, int, int)

public ProgressMonitor(Component sample code for java.awt.Component definition code for java.awt.Component  parentComponent,
                       Object sample code for java.lang.Object definition code for java.lang.Object  message,
                       String sample code for java.lang.String definition code for java.lang.String  note,
                       int min,
                       int max)
Constructs a graphic object that shows progress, typically by filling in a rectangular bar as the process nears completion.

Parameters:
parentComponent - the parent component for the dialog box
message - a descriptive message that will be shown to the user to indicate what operation is being monitored. This does not change as the operation progresses. See the message parameters to methods in JOptionPane.message sample code for javax.swing.JOptionPane.message definition code for javax.swing.JOptionPane.message for the range of values.
note - a short note describing the state of the operation. As the operation progresses, you can call setNote to change the note displayed. This is used, for example, in operations that iterate through a list of files to show the name of the file being processes. If note is initially null, there will be no note line in the dialog box and setNote will be ineffective
min - the lower bound of the range
max - the upper bound of the range
See Also:
JDialog sample code for javax.swing.JDialog definition code for javax.swing.JDialog , JOptionPane sample code for javax.swing.JOptionPane definition code for javax.swing.JOptionPane
Method Detail

setProgress sample code for javax.swing.ProgressMonitor.setProgress(int) definition code for javax.swing.ProgressMonitor.setProgress(int)

public void setProgress(int nv)
Indicate the progress of the operation being monitored. If the specified value is >= the maximum, the progress monitor is closed.

Parameters:
nv - an int specifying the current value, between the maximum and minimum specified for this component
See Also:
setMinimum(int) sample code for javax.swing.ProgressMonitor.setMinimum(int) definition code for javax.swing.ProgressMonitor.setMinimum(int) , setMaximum(int) sample code for javax.swing.ProgressMonitor.setMaximum(int) definition code for javax.swing.ProgressMonitor.setMaximum(int) , close() sample code for javax.swing.ProgressMonitor.close() definition code for javax.swing.ProgressMonitor.close()

close sample code for javax.swing.ProgressMonitor.close() definition code for javax.swing.ProgressMonitor.close()

public void close()
Indicate that the operation is complete. This happens automatically when the value set by setProgress is >= max, but it may be called earlier if the operation ends early.


getMinimum sample code for javax.swing.ProgressMonitor.getMinimum() definition code for javax.swing.ProgressMonitor.getMinimum()

public int getMinimum()
Returns the minimum value -- the lower end of the progress value.

Returns:
an int representing the minimum value
See Also:
setMinimum(int) sample code for javax.swing.ProgressMonitor.setMinimum(int) definition code for javax.swing.ProgressMonitor.setMinimum(int)

setMinimum sample code for javax.swing.ProgressMonitor.setMinimum(int) definition code for javax.swing.ProgressMonitor.setMinimum(int)

public void setMinimum(int m)
Specifies the minimum value.

Parameters:
m - an int specifying the minimum value
See Also:
getMinimum() sample code for javax.swing.ProgressMonitor.getMinimum() definition code for javax.swing.ProgressMonitor.getMinimum()

getMaximum sample code for javax.swing.ProgressMonitor.getMaximum() definition code for javax.swing.ProgressMonitor.getMaximum()

public int getMaximum()
Returns the maximum value -- the higher end of the progress value.

Returns:
an int representing the maximum value
See Also:
setMaximum(int) sample code for javax.swing.ProgressMonitor.setMaximum(int) definition code for javax.swing.ProgressMonitor.setMaximum(int)

setMaximum sample code for javax.swing.ProgressMonitor.setMaximum(int) definition code for javax.swing.ProgressMonitor.setMaximum(int)

public void setMaximum(int m)
Specifies the maximum value.

Parameters:
m - an int specifying the maximum value
See Also:
getMaximum() sample code for javax.swing.ProgressMonitor.getMaximum() definition code for javax.swing.ProgressMonitor.getMaximum()

isCanceled sample code for javax.swing.ProgressMonitor.isCanceled() definition code for javax.swing.ProgressMonitor.isCanceled()

public boolean isCanceled()
Returns true if the user hits the Cancel button in the progress dialog.


setMillisToDecideToPopup sample code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int)

public void setMillisToDecideToPopup(int millisToDecideToPopup)
Specifies the amount of time to wait before deciding whether or not to popup a progress monitor.

Parameters:
millisToDecideToPopup - an int specifying the time to wait, in milliseconds
See Also:
getMillisToDecideToPopup() sample code for javax.swing.ProgressMonitor.getMillisToDecideToPopup() definition code for javax.swing.ProgressMonitor.getMillisToDecideToPopup()

getMillisToDecideToPopup sample code for javax.swing.ProgressMonitor.getMillisToDecideToPopup() definition code for javax.swing.ProgressMonitor.getMillisToDecideToPopup()

public int getMillisToDecideToPopup()
Returns the amount of time this object waits before deciding whether or not to popup a progress monitor.

See Also:
setMillisToDecideToPopup(int) sample code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToDecideToPopup(int)

setMillisToPopup sample code for javax.swing.ProgressMonitor.setMillisToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToPopup(int)

public void setMillisToPopup(int millisToPopup)
Specifies 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.)

Parameters:
millisToPopup - an int specifying the time in milliseconds
See Also:
getMillisToPopup() sample code for javax.swing.ProgressMonitor.getMillisToPopup() definition code for javax.swing.ProgressMonitor.getMillisToPopup()

getMillisToPopup sample code for javax.swing.ProgressMonitor.getMillisToPopup() definition code for javax.swing.ProgressMonitor.getMillisToPopup()

public int getMillisToPopup()
Returns the amount of time it will take for the popup to appear.

See Also:
setMillisToPopup(int) sample code for javax.swing.ProgressMonitor.setMillisToPopup(int) definition code for javax.swing.ProgressMonitor.setMillisToPopup(int)

setNote sample code for javax.swing.ProgressMonitor.setNote(java.lang.String) definition code for javax.swing.ProgressMonitor.setNote(java.lang.String)

public void setNote(String sample code for java.lang.String definition code for java.lang.String  note)
Specifies the additional note that is displayed along with the progress message. Used, for example, to show which file the is currently being copied during a multiple-file copy.

Parameters:
note - a String specifying the note to display
See Also:
getNote() sample code for javax.swing.ProgressMonitor.getNote() definition code for javax.swing.ProgressMonitor.getNote()

getNote sample code for javax.swing.ProgressMonitor.getNote() definition code for javax.swing.ProgressMonitor.getNote()

public String sample code for java.lang.String definition code for java.lang.String  getNote()
Specifies the additional note that is displayed along with the progress message.

Returns:
a String specifying the note to display
See Also:
setNote(java.lang.String) sample code for javax.swing.ProgressMonitor.setNote(java.lang.String) definition code for javax.swing.ProgressMonitor.setNote(java.lang.String)

getAccessibleContext sample code for javax.swing.ProgressMonitor.getAccessibleContext() definition code for javax.swing.ProgressMonitor.getAccessibleContext()

public AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext  getAccessibleContext()
Gets the AccessibleContext for the ProgressMonitor

Specified by:
getAccessibleContext sample code for javax.accessibility.Accessible.getAccessibleContext() definition code for javax.accessibility.Accessible.getAccessibleContext() in interface Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible
Returns:
the AccessibleContext for the ProgressMonitor
Since:
1.5