- java.lang.Object
-
- javax.swing.ProgressMonitor
-
- All Implemented Interfaces:
- Accessible
public class ProgressMonitor extends Object implements 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
ProgressMonitor.AccessibleProgressMonitor
AccessibleProgressMonitor
implements accessibility support for theProgressMonitor
class.
-
Field Summary
Fields Modifier and Type Field and Description protected AccessibleContext
accessibleContext
TheAccessibleContext
for theProgressMonitor
-
Constructor Summary
Constructors Constructor and Description ProgressMonitor(Component parentComponent, Object message, 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
Methods Modifier and Type Method and Description void
close()
Indicate that the operation is complete.AccessibleContext
getAccessibleContext()
Gets theAccessibleContext
for theProgressMonitor
int
getMaximum()
Returns the maximum value -- the higher end of the progress value.int
getMillisToDecideToPopup()
Returns the amount of time this object waits before deciding whether or not to popup a progress monitor.int
getMillisToPopup()
Returns the amount of time it will take for the popup to appear.int
getMinimum()
Returns the minimum value -- the lower end of the progress value.String
getNote()
Specifies the additional note that is displayed along with the progress message.boolean
isCanceled()
Returns true if the user hits the Cancel button in the progress dialog.void
setMaximum(int m)
Specifies the maximum value.void
setMillisToDecideToPopup(int millisToDecideToPopup)
Specifies the amount of time to wait before deciding whether or not to popup a progress monitor.void
setMillisToPopup(int millisToPopup)
Specifies the amount of time it will take for the popup to appear.void
setMinimum(int m)
Specifies the minimum value.void
setNote(String note)
Specifies the additional note that is displayed along with the progress message.void
setProgress(int nv)
Indicate the progress of the operation being monitored.
-
-
-
Field Detail
-
accessibleContext
protected AccessibleContext accessibleContext
TheAccessibleContext
for theProgressMonitor
- Since:
- 1.5
-
-
Constructor Detail
-
ProgressMonitor
public ProgressMonitor(Component parentComponent, Object message, 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 boxmessage
- 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 inJOptionPane.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 ineffectivemin
- the lower bound of the rangemax
- the upper bound of the range- See Also:
JDialog
,JOptionPane
-
-
Method Detail
-
setProgress
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)
,setMaximum(int)
,close()
-
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
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)
-
setMinimum
public void setMinimum(int m)
Specifies the minimum value.- Parameters:
m
- an int specifying the minimum value- See Also:
getMinimum()
-
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)
-
setMaximum
public void setMaximum(int m)
Specifies the maximum value.- Parameters:
m
- an int specifying the maximum value- See Also:
getMaximum()
-
isCanceled
public boolean isCanceled()
Returns true if the user hits the Cancel button in the progress dialog.
-
setMillisToDecideToPopup
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()
-
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)
-
setMillisToPopup
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()
-
getMillisToPopup
public int getMillisToPopup()
Returns the amount of time it will take for the popup to appear.- See Also:
setMillisToPopup(int)
-
setNote
public void setNote(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()
-
getNote
public 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)
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets theAccessibleContext
for theProgressMonitor
- Specified by:
getAccessibleContext
in interfaceAccessible
- Returns:
- the
AccessibleContext
for theProgressMonitor
- Since:
- 1.5
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/progressmonitor.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.