net.sf.swinglib.components
Class ProgressMonitor

java.lang.Object
  extended by net.sf.swinglib.components.ProgressMonitor

public class ProgressMonitor
extends Object

Creates and manages a standardized progress dialog. Any of the public methods on this class (including the constructor) may be executed from any thread; the actual operations are queued for the event thread.

The dialog is displayed by calling show(), hidden by calling hide(). It is not actually created until the first call to show(); the constructor merely records information. Nor is it disposed by calling hide(); you must explicitly call dispose().


Nested Class Summary
static class ProgressMonitor.Options
          Options to control the dialog's appearance.
 
Constructor Summary
ProgressMonitor(JFrame owner, String title, String text, Action action, ProgressMonitor.Options... options)
          Base constructor, allowing customization of the dialog's appearance and behavior.
ProgressMonitor(JFrame owner, String title, String text, ProgressMonitor.Options... options)
          Convenience constructor for a dialog that does not have an action button.
 
Method Summary
 void clearProgress()
          Switches the dialog to indeterminate mode.
 void dispose()
          Disposes the dialog, allowing the JVM to reclaim all resources.
 void hide()
          Hides the dialog, but does not dispose it; also resets progress data.
 void setProgress(int min, int current, int max)
          Sets the dialog's progress indicator to the given values.
 void setStatus(String message)
          Sets the status text, if the dialog was constructed with that option.
 ProgressMonitor show()
          Displays the dialog, constructing it if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressMonitor

public ProgressMonitor(JFrame owner,
                       String title,
                       String text,
                       Action action,
                       ProgressMonitor.Options... options)
Base constructor, allowing customization of the dialog's appearance and behavior. Note that the actual dialog is constructed on the first call to show().

Parameters:
owner - The dialog owner; may be null, in which case Swing will generate a hidden owner frame.
title - Text to display in the dialog window's title area; may be null, in which case the title is left empty.
text - Text to display in the body of the dialog; usually gives an overall description of what's happening. May be null.
action - If not null, the dialog will display a single button that invokes this action (normally used for a cancel button).
options - Zero or more options controlling the dialog's appearance and behavior.

ProgressMonitor

public ProgressMonitor(JFrame owner,
                       String title,
                       String text,
                       ProgressMonitor.Options... options)
Convenience constructor for a dialog that does not have an action button.

Parameters:
owner - The dialog owner; may be null, in which case Swing will generate a hidden owner frame.
title - Text to display in the dialog window's title area; may be null, in which case the title is left empty.
text - Text to display in the body of the dialog; usually gives an overall description of what's happening. May be null.
options - Zero or more options controlling the dialog's appearance and behavior.
Method Detail

show

public ProgressMonitor show()
Displays the dialog, constructing it if necessary. The dialog initially displays in indeterminate mode, unless setProgress(int, int, int) was called prior to this method.


hide

public void hide()
Hides the dialog, but does not dispose it; also resets progress data. This method is useful if the dialog is to be reused.


dispose

public void dispose()
Disposes the dialog, allowing the JVM to reclaim all resources. Any future calls to show() will have to reconstruct it.


setProgress

public void setProgress(int min,
                        int current,
                        int max)
Sets the dialog's progress indicator to the given values. If the dialog was previously in indeterminate mode, this will switch it to determinate mode.

Parameters:
min - The minimum progress value.
current - The current progress value; this sets the position of the dialog's indicator.
max - The maximum progress value.

setStatus

public void setStatus(String message)
Sets the status text, if the dialog was constructed with that option.


clearProgress

public void clearProgress()
Switches the dialog to indeterminate mode.