A component that visually displays the progress of some task. As the task progresses towards completion, the progress bar displays the task's percentage of completion. This percentage is typically represented visually by a rectangle which starts out empty and gradually becomes filled in as the task progresses. In addition, the progress bar can display a textual representation of this percentage.
JProgressBar uses a BoundedRangeModel as its data model, with the value property representing the "current" state of the task, and the minimum and maximum properties representing the beginning and end points, respectively.
To indicate that a task of unknown length is executing, you can put a progress bar into indeterminate mode. While the bar is in indeterminate mode, it animates constantly to show that work is occurring. As soon as you can determine the task's length and amount of progress, you should update the progress bar's value and switch it back to determinate mode.
Here is an example of creating a progress bar, where task is an object (representing some piece of work) which returns information about the progress of the task:
progressBar = new JProgressBar(0, task.getLengthOfTask()); progressBar.setValue(0); progressBar.setStringPainted(true);
Here is an example of querying the current state of the task, and using the returned value to update the progress bar:
progressBar.setValue(task.getCurrent());
Here is an example of putting a progress bar into indeterminate mode, and then switching back to determinate mode once the length of the task is known:
progressBar = new JProgressBar(); ...//when the task of (initially) unknown length begins: progressBar.setIndeterminate(true); ...//do some work; get length of task... progressBar.setMaximum(newLength); progressBar.setValue(newValue); progressBar.setIndeterminate(false);
For complete examples and further documentation see How to Monitor Progress, a section in The Java Tutorial.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
A component that visually displays the progress of some task. As the task progresses towards completion, the progress bar displays the task's percentage of completion. This percentage is typically represented visually by a rectangle which starts out empty and gradually becomes filled in as the task progresses. In addition, the progress bar can display a textual representation of this percentage. JProgressBar uses a BoundedRangeModel as its data model, with the value property representing the "current" state of the task, and the minimum and maximum properties representing the beginning and end points, respectively. To indicate that a task of unknown length is executing, you can put a progress bar into indeterminate mode. While the bar is in indeterminate mode, it animates constantly to show that work is occurring. As soon as you can determine the task's length and amount of progress, you should update the progress bar's value and switch it back to determinate mode. Here is an example of creating a progress bar, where task is an object (representing some piece of work) which returns information about the progress of the task: progressBar = new JProgressBar(0, task.getLengthOfTask()); progressBar.setValue(0); progressBar.setStringPainted(true); Here is an example of querying the current state of the task, and using the returned value to update the progress bar: progressBar.setValue(task.getCurrent()); Here is an example of putting a progress bar into indeterminate mode, and then switching back to determinate mode once the length of the task is known: progressBar = new JProgressBar(); ...//when the task of (initially) unknown length begins: progressBar.setIndeterminate(true); ...//do some work; get length of task... progressBar.setMaximum(newLength); progressBar.setValue(newValue); progressBar.setIndeterminate(false); For complete examples and further documentation see How to Monitor Progress, a section in The Java Tutorial. Warning: Swing is not thread safe. For more information see Swing's Threading Policy. Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
(->j-progress-bar)
(->j-progress-bar orient)
(->j-progress-bar min max)
(->j-progress-bar orient min max)
Constructor.
Creates a progress bar using the specified orientation, minimum, and maximum. By default, a border is painted but a progress string is not. Sets the initial value of the progress bar to the specified minimum.
The BoundedRangeModel that holds the progress bar's data handles any issues that may arise from improperly setting the minimum, initial, and maximum values on the progress bar. See the BoundedRangeModel documentation for details.
orient - the desired orientation of the progress bar - int
min - the minimum value of the progress bar - int
max - the maximum value of the progress bar - int
throws: java.lang.IllegalArgumentException - if orient is an illegal value
Constructor. Creates a progress bar using the specified orientation, minimum, and maximum. By default, a border is painted but a progress string is not. Sets the initial value of the progress bar to the specified minimum. The BoundedRangeModel that holds the progress bar's data handles any issues that may arise from improperly setting the minimum, initial, and maximum values on the progress bar. See the BoundedRangeModel documentation for details. orient - the desired orientation of the progress bar - `int` min - the minimum value of the progress bar - `int` max - the maximum value of the progress bar - `int` throws: java.lang.IllegalArgumentException - if orient is an illegal value
(add-change-listener this l)
Adds the specified ChangeListener to the progress bar.
l - the ChangeListener to add - javax.swing.event.ChangeListener
Adds the specified ChangeListener to the progress bar. l - the ChangeListener to add - `javax.swing.event.ChangeListener`
(border-painted? this)
Returns the borderPainted property.
returns: the value of the borderPainted property - boolean
Returns the borderPainted property. returns: the value of the borderPainted property - `boolean`
(get-accessible-context this)
Gets the AccessibleContext associated with this JProgressBar. For progress bars, the AccessibleContext takes the form of an AccessibleJProgressBar. A new AccessibleJProgressBar instance is created if necessary.
returns: an AccessibleJProgressBar that serves as the
AccessibleContext of this JProgressBar - javax.accessibility.AccessibleContext
Gets the AccessibleContext associated with this JProgressBar. For progress bars, the AccessibleContext takes the form of an AccessibleJProgressBar. A new AccessibleJProgressBar instance is created if necessary. returns: an AccessibleJProgressBar that serves as the AccessibleContext of this JProgressBar - `javax.accessibility.AccessibleContext`
(get-change-listeners this)
Returns an array of all the ChangeListeners added to this progress bar with addChangeListener.
returns: all of the ChangeListeners added or an empty
array if no listeners have been added - javax.swing.event.ChangeListener[]
Returns an array of all the ChangeListeners added to this progress bar with addChangeListener. returns: all of the ChangeListeners added or an empty array if no listeners have been added - `javax.swing.event.ChangeListener[]`
(get-maximum this)
Returns the progress bar's maximum value from the BoundedRangeModel.
returns: the progress bar's maximum value - int
Returns the progress bar's maximum value from the BoundedRangeModel. returns: the progress bar's maximum value - `int`
(get-minimum this)
Returns the progress bar's minimum value from the BoundedRangeModel.
returns: the progress bar's minimum value - int
Returns the progress bar's minimum value from the BoundedRangeModel. returns: the progress bar's minimum value - `int`
(get-model this)
Returns the data model used by this progress bar.
returns: the BoundedRangeModel currently in use - javax.swing.BoundedRangeModel
Returns the data model used by this progress bar. returns: the BoundedRangeModel currently in use - `javax.swing.BoundedRangeModel`
(get-orientation this)
Returns SwingConstants.VERTICAL or SwingConstants.HORIZONTAL, depending on the orientation of the progress bar. The default orientation is SwingConstants.HORIZONTAL.
returns: HORIZONTAL or VERTICAL - int
Returns SwingConstants.VERTICAL or SwingConstants.HORIZONTAL, depending on the orientation of the progress bar. The default orientation is SwingConstants.HORIZONTAL. returns: HORIZONTAL or VERTICAL - `int`
(get-percent-complete this)
Returns the percent complete for the progress bar. Note that this number is between 0.0 and 1.0.
returns: the percent complete for this progress bar - double
Returns the percent complete for the progress bar. Note that this number is between 0.0 and 1.0. returns: the percent complete for this progress bar - `double`
(get-string this)
Returns a String representation of the current progress. By default, this returns a simple percentage String based on the value returned from getPercentComplete. An example would be the "42%". You can change this by calling setString.
returns: the value of the progress string, or a simple percentage string
if the progress string is null - java.lang.String
Returns a String representation of the current progress. By default, this returns a simple percentage String based on the value returned from getPercentComplete. An example would be the "42%". You can change this by calling setString. returns: the value of the progress string, or a simple percentage string if the progress string is null - `java.lang.String`
(get-ui this)
Returns the look-and-feel object that renders this component.
returns: the ProgressBarUI object that renders this component - javax.swing.plaf.ProgressBarUI
Returns the look-and-feel object that renders this component. returns: the ProgressBarUI object that renders this component - `javax.swing.plaf.ProgressBarUI`
(get-ui-class-id this)
Returns the name of the look-and-feel class that renders this component.
returns: the string "ProgressBarUI" - java.lang.String
Returns the name of the look-and-feel class that renders this component. returns: the string "ProgressBarUI" - `java.lang.String`
(get-value this)
Returns the progress bar's current value from the BoundedRangeModel. The value is always between the minimum and maximum values, inclusive.
returns: the current value of the progress bar - int
Returns the progress bar's current value from the BoundedRangeModel. The value is always between the minimum and maximum values, inclusive. returns: the current value of the progress bar - `int`
(indeterminate? this)
Returns the value of the indeterminate property.
returns: the value of the indeterminate property - boolean
Returns the value of the indeterminate property. returns: the value of the indeterminate property - `boolean`
(remove-change-listener this l)
Removes a ChangeListener from the progress bar.
l - the ChangeListener to remove - javax.swing.event.ChangeListener
Removes a ChangeListener from the progress bar. l - the ChangeListener to remove - `javax.swing.event.ChangeListener`
(set-border-painted this b)
Sets the borderPainted property, which is true if the progress bar should paint its border. The default value for this property is true. Some look and feels might not implement painted borders; they will ignore this property.
b - true if the progress bar should paint its border; otherwise, false - boolean
Sets the borderPainted property, which is true if the progress bar should paint its border. The default value for this property is true. Some look and feels might not implement painted borders; they will ignore this property. b - true if the progress bar should paint its border; otherwise, false - `boolean`
(set-indeterminate this new-value)
Sets the indeterminate property of the progress bar, which determines whether the progress bar is in determinate or indeterminate mode. An indeterminate progress bar continuously displays animation indicating that an operation of unknown length is occurring. By default, this property is false. Some look and feels might not support indeterminate progress bars; they will ignore this property.
See How to Monitor Progress for examples of using indeterminate progress bars.
new-value - true if the progress bar should change to indeterminate mode; false if it should revert to normal. - boolean
Sets the indeterminate property of the progress bar, which determines whether the progress bar is in determinate or indeterminate mode. An indeterminate progress bar continuously displays animation indicating that an operation of unknown length is occurring. By default, this property is false. Some look and feels might not support indeterminate progress bars; they will ignore this property. See How to Monitor Progress for examples of using indeterminate progress bars. new-value - true if the progress bar should change to indeterminate mode; false if it should revert to normal. - `boolean`
(set-maximum this n)
Sets the progress bar's maximum value (stored in the progress bar's data model) to n.
The underlying BoundedRangeModel handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details.
If the maximum value is different from the previous maximum, all change listeners are notified.
n - the new maximum - int
Sets the progress bar's maximum value (stored in the progress bar's data model) to n. The underlying BoundedRangeModel handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details. If the maximum value is different from the previous maximum, all change listeners are notified. n - the new maximum - `int`
(set-minimum this n)
Sets the progress bar's minimum value (stored in the progress bar's data model) to n.
The data model (a BoundedRangeModel instance) handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details.
If the minimum value is different from the previous minimum, all change listeners are notified.
n - the new minimum - int
Sets the progress bar's minimum value (stored in the progress bar's data model) to n. The data model (a BoundedRangeModel instance) handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details. If the minimum value is different from the previous minimum, all change listeners are notified. n - the new minimum - `int`
(set-model this new-model)
Sets the data model used by the JProgressBar. Note that the BoundedRangeModel's extent is not used, and is set to 0.
new-model - the BoundedRangeModel to use - javax.swing.BoundedRangeModel
Sets the data model used by the JProgressBar. Note that the BoundedRangeModel's extent is not used, and is set to 0. new-model - the BoundedRangeModel to use - `javax.swing.BoundedRangeModel`
(set-orientation this new-orientation)
Sets the progress bar's orientation to newOrientation, which must be SwingConstants.VERTICAL or SwingConstants.HORIZONTAL. The default orientation is SwingConstants.HORIZONTAL.
new-orientation - HORIZONTAL or VERTICAL - int
throws: java.lang.IllegalArgumentException - if newOrientation is an illegal value
Sets the progress bar's orientation to newOrientation, which must be SwingConstants.VERTICAL or SwingConstants.HORIZONTAL. The default orientation is SwingConstants.HORIZONTAL. new-orientation - HORIZONTAL or VERTICAL - `int` throws: java.lang.IllegalArgumentException - if newOrientation is an illegal value
(set-string this s)
Sets the value of the progress string. By default, this string is null, implying the built-in behavior of using a simple percent string. If you have provided a custom progress string and want to revert to the built-in behavior, set the string back to null.
The progress string is painted only if the isStringPainted method returns true.
s - the value of the progress string - java.lang.String
Sets the value of the progress string. By default, this string is null, implying the built-in behavior of using a simple percent string. If you have provided a custom progress string and want to revert to the built-in behavior, set the string back to null. The progress string is painted only if the isStringPainted method returns true. s - the value of the progress string - `java.lang.String`
(set-string-painted this b)
Sets the value of the stringPainted property, which determines whether the progress bar should render a progress string. The default is false, meaning no string is painted. Some look and feels might not support progress strings or might support them only when the progress bar is in determinate mode.
b - true if the progress bar should render a string - boolean
Sets the value of the stringPainted property, which determines whether the progress bar should render a progress string. The default is false, meaning no string is painted. Some look and feels might not support progress strings or might support them only when the progress bar is in determinate mode. b - true if the progress bar should render a string - `boolean`
(set-ui this ui)
Sets the look-and-feel object that renders this component.
ui - a ProgressBarUI object - javax.swing.plaf.ProgressBarUI
Sets the look-and-feel object that renders this component. ui - a ProgressBarUI object - `javax.swing.plaf.ProgressBarUI`
(set-value this n)
Sets the progress bar's current value to n. This method forwards the new value to the model.
The data model (an instance of BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details.
If the new value is different from the previous value, all change listeners are notified.
n - the new value - int
Sets the progress bar's current value to n. This method forwards the new value to the model. The data model (an instance of BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See the BoundedRangeModel documentation for details. If the new value is different from the previous value, all change listeners are notified. n - the new value - `int`
(string-painted? this)
Returns the value of the stringPainted property.
returns: the value of the stringPainted property - boolean
Returns the value of the stringPainted property. returns: the value of the stringPainted property - `boolean`
(update-ui this)
Resets the UI property to a value from the current look and feel.
Resets the UI property to a value from the current look and feel.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close