Package Summary Overview Summary

### class:JProgressBar [NONE]
- All Implemented Interfaces: ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
      public class JProgressBar
      extends JComponent
      implements SwingConstants, Accessible
  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`. Since: 1.2 See Also: `BasicProgressBarUI`, `BoundedRangeModel`, `SwingWorker`

### field:orientation [NONE]
- #### orientation
      protected int orientation
Whether the progress bar is horizontal or vertical. The default is `HORIZONTAL`. See Also: `setOrientation(int)`

### field:paintBorder [NONE]
- #### paintBorder
      protected boolean paintBorder
Whether to display a border around the progress bar. The default is `true`. See Also: `setBorderPainted(boolean)`

### field:model [NONE]
- #### model
      protected BoundedRangeModel model
The object that holds the data for the progress bar. See Also: `setModel(javax.swing.BoundedRangeModel)`

### field:progressString [NONE]
- #### progressString
      protected String progressString
An optional string that can be displayed on the progress bar. The default is `null`. Setting this to a non-`null` value does not imply that the string will be displayed. To display the string, `paintString` must be `true`. See Also: `setString(java.lang.String)`, `setStringPainted(boolean)`

### field:paintString [NONE]
- #### paintString
      protected boolean paintString
Whether to display a string of text on the progress bar. The default is `false`. Setting this to `true` causes a textual display of the progress to be rendered on the progress bar. If the `progressString` is `null`, the percentage of completion is displayed on the progress bar. Otherwise, the `progressString` is rendered on the progress bar. See Also: `setStringPainted(boolean)`, `setString(java.lang.String)`

### field:changeEvent [NONE]
- #### changeEvent
      protected transient ChangeEvent changeEvent
Only one `ChangeEvent` is needed per instance since the event's only interesting property is the immutable source, which is the progress bar. The event is lazily created the first time that an event notification is fired. See Also: `fireStateChanged()`

### field:changeListener [NONE]
- #### changeListener
      protected ChangeListener changeListener
Listens for change events sent by the progress bar's model, redispatching them to change-event listeners registered upon this progress bar. See Also: `createChangeListener()`

### constructor:JProgressBar() [NONE]
- #### JProgressBar
      public JProgressBar()
Creates a horizontal progress bar that displays a border but no progress string. The initial and minimum values are 0, and the maximum is 100. See Also: `setOrientation(int)`, `setBorderPainted(boolean)`, `setStringPainted(boolean)`, `setString(java.lang.String)`, `setIndeterminate(boolean)`

### constructor:JProgressBar(int) [NONE]
- #### JProgressBar
      public JProgressBar(int orient)
Creates a progress bar with the specified orientation, which can be either `SwingConstants.VERTICAL` or `SwingConstants.HORIZONTAL`. By default, a border is painted but a progress string is not. The initial and minimum values are 0, and the maximum is 100. Parameters: `orient` - the desired orientation of the progress bar Throws: `IllegalArgumentException` - if `orient` is an illegal value See Also: `setOrientation(int)`, `setBorderPainted(boolean)`, `setStringPainted(boolean)`, `setString(java.lang.String)`, `setIndeterminate(boolean)`

### constructor:JProgressBar(int, int) [NONE]
- #### JProgressBar
      public JProgressBar(int min,
                          int max)
Creates a horizontal progress bar with the specified minimum and maximum. Sets the initial value of the progress bar to the specified minimum. By default, a border is painted but a progress string is not. 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. Parameters: `min` - the minimum value of the progress bar `max` - the maximum value of the progress bar See Also: `BoundedRangeModel`, `setOrientation(int)`, `setBorderPainted(boolean)`, `setStringPainted(boolean)`, `setString(java.lang.String)`, `setIndeterminate(boolean)`

### constructor:JProgressBar(int, int, int) [NONE]
- #### JProgressBar
      public JProgressBar(int orient,
                          int min,
                          int max)
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. Parameters: `orient` - the desired orientation of the progress bar `min` - the minimum value of the progress bar `max` - the maximum value of the progress bar Throws: `IllegalArgumentException` - if `orient` is an illegal value See Also: `BoundedRangeModel`, `setOrientation(int)`, `setBorderPainted(boolean)`, `setStringPainted(boolean)`, `setString(java.lang.String)`, `setIndeterminate(boolean)`

### constructor:JProgressBar(javax.swing.BoundedRangeModel) [NONE]
- #### JProgressBar
      public JProgressBar(BoundedRangeModel newModel)
Creates a horizontal progress bar that uses the specified model to hold the progress bar's data. By default, a border is painted but a progress string is not. Parameters: `newModel` - the data model for the progress bar See Also: `setOrientation(int)`, `setBorderPainted(boolean)`, `setStringPainted(boolean)`, `setString(java.lang.String)`, `setIndeterminate(boolean)`

### method:getOrientation() [NONE]
- #### getOrientation
      public int getOrientation()
Returns `SwingConstants.VERTICAL` or `SwingConstants.HORIZONTAL`, depending on the orientation of the progress bar. The default orientation is `SwingConstants.HORIZONTAL`. Returns: `HORIZONTAL` or `VERTICAL` See Also: `setOrientation(int)`

### method:setOrientation(int) [NONE]
- #### setOrientation
      public void setOrientation(int newOrientation)
Sets the progress bar's orientation to `newOrientation`, which must be `SwingConstants.VERTICAL` or `SwingConstants.HORIZONTAL`. The default orientation is `SwingConstants.HORIZONTAL`. Parameters: `newOrientation` - `HORIZONTAL` or `VERTICAL` Throws: `IllegalArgumentException` - if `newOrientation` is an illegal value See Also: `getOrientation()`

### method:isStringPainted() [NONE]
- #### isStringPainted
      public boolean isStringPainted()
Returns the value of the `stringPainted` property. Returns: the value of the `stringPainted` property See Also: `setStringPainted(boolean)`, `setString(java.lang.String)`

### method:setStringPainted(boolean) [NONE]
- #### setStringPainted
      public void setStringPainted(boolean 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. Parameters: `b` - `true` if the progress bar should render a string See Also: `isStringPainted()`, `setString(java.lang.String)`

### method:getString() [NONE]
- #### getString
      public String getString()
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` See Also: `setString(java.lang.String)`

### method:setString(java.lang.String) [NONE]
- #### setString
      public void setString(String 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`. Parameters: `s` - the value of the progress string See Also: `getString()`, `setStringPainted(boolean)`, `isStringPainted()`

### method:getPercentComplete() [NONE]
- #### getPercentComplete
      public double getPercentComplete()
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

### method:isBorderPainted() [NONE]
- #### isBorderPainted
      public boolean isBorderPainted()
Returns the `borderPainted` property. Returns: the value of the `borderPainted` property See Also: `setBorderPainted(boolean)`

### method:setBorderPainted(boolean) [NONE]
- #### setBorderPainted
      public void setBorderPainted(boolean 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. Parameters: `b` - `true` if the progress bar should paint its border; otherwise, `false` See Also: `isBorderPainted()`

### method:paintBorder(java.awt.Graphics) [NONE]
- #### paintBorder
      protected void paintBorder(Graphics g)
Paints the progress bar's border if the `borderPainted` property is `true`. Overrides: `paintBorder` in class `JComponent` Parameters: `g` - the `Graphics` context within which to paint the border See Also: `JComponent.paint(java.awt.Graphics)`, `JComponent.setBorder(javax.swing.border.Border)`, `isBorderPainted()`, `setBorderPainted(boolean)`

### method:getUI() [NONE]
- #### getUI
      public ProgressBarUI getUI()
Returns the look-and-feel object that renders this component. Returns: the `ProgressBarUI` object that renders this component

### method:setUI(javax.swing.plaf.ProgressBarUI) [NONE]
- #### setUI
      public void setUI(ProgressBarUI ui)
Sets the look-and-feel object that renders this component. Parameters: `ui` - a `ProgressBarUI` object See Also: `UIDefaults.getUI(javax.swing.JComponent)`

### method:updateUI() [NONE]
- #### updateUI
      public void updateUI()
Resets the UI property to a value from the current look and feel. Overrides: `updateUI` in class `JComponent` See Also: `JComponent.updateUI()`

### method:getUIClassID() [NONE]
- #### getUIClassID
      public String getUIClassID()
Returns the name of the look-and-feel class that renders this component. Overrides: `getUIClassID` in class `JComponent` Returns: the string "ProgressBarUI" See Also: `JComponent.getUIClassID()`, `UIDefaults.getUI(javax.swing.JComponent)`

### method:createChangeListener() [NONE]
- #### createChangeListener
      protected ChangeListener createChangeListener()
Subclasses that want to handle change events from the model differently can override this to return an instance of a custom `ChangeListener` implementation. The default `ChangeListener` simply calls the `fireStateChanged` method to forward `ChangeEvent`s to the `ChangeListener`s that have been added directly to the progress bar. Returns: the instance of a custom `ChangeListener` implementation. See Also: `changeListener`, `fireStateChanged()`, `ChangeListener`, `BoundedRangeModel`

### method:addChangeListener(javax.swing.event.ChangeListener) [NONE]
- #### addChangeListener
      public void addChangeListener(ChangeListener l)
Adds the specified `ChangeListener` to the progress bar. Parameters: `l` - the `ChangeListener` to add

### method:removeChangeListener(javax.swing.event.ChangeListener) [NONE]
- #### removeChangeListener
      public void removeChangeListener(ChangeListener l)
Removes a `ChangeListener` from the progress bar. Parameters: `l` - the `ChangeListener` to remove

### method:getChangeListeners() [NONE]
- #### getChangeListeners
      public ChangeListener[] getChangeListeners()
Returns an array of all the `ChangeListener`s added to this progress bar with `addChangeListener`. Returns: all of the `ChangeListener`s added or an empty array if no listeners have been added Since: 1.4

### method:fireStateChanged() [NONE]
- #### fireStateChanged
      protected void fireStateChanged()
Send a `ChangeEvent`, whose source is this `JProgressBar`, to all `ChangeListener`s that have registered interest in `ChangeEvent`s. This method is called each time a `ChangeEvent` is received from the model. The event instance is created if necessary, and stored in `changeEvent`. See Also: `addChangeListener(javax.swing.event.ChangeListener)`, `EventListenerList`

### method:getModel() [NONE]
- #### getModel
      public BoundedRangeModel getModel()
Returns the data model used by this progress bar. Returns: the `BoundedRangeModel` currently in use See Also: `setModel(javax.swing.BoundedRangeModel)`, `BoundedRangeModel`

### method:setModel(javax.swing.BoundedRangeModel) [NONE]
- #### setModel
      public void setModel(BoundedRangeModel newModel)
Sets the data model used by the `JProgressBar`. Note that the `BoundedRangeModel`'s `extent` is not used, and is set to `0`. Parameters: `newModel` - the `BoundedRangeModel` to use

### method:getValue() [NONE]
- #### getValue
      public int getValue()
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 See Also: `setValue(int)`, `BoundedRangeModel.getValue()`

### method:getMinimum() [NONE]
- #### getMinimum
      public int getMinimum()
Returns the progress bar's `minimum` value from the `BoundedRangeModel`. Returns: the progress bar's minimum value See Also: `setMinimum(int)`, `BoundedRangeModel.getMinimum()`

### method:getMaximum() [NONE]
- #### getMaximum
      public int getMaximum()
Returns the progress bar's `maximum` value from the `BoundedRangeModel`. Returns: the progress bar's maximum value See Also: `setMaximum(int)`, `BoundedRangeModel.getMaximum()`

### method:setValue(int) [NONE]
- #### setValue
      public void setValue(int 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. Parameters: `n` - the new value See Also: `getValue()`, `addChangeListener(javax.swing.event.ChangeListener)`, `BoundedRangeModel.setValue(int)`

### method:setMinimum(int) [NONE]
- #### setMinimum
      public void setMinimum(int 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. Parameters: `n` - the new minimum See Also: `getMinimum()`, `addChangeListener(javax.swing.event.ChangeListener)`, `BoundedRangeModel.setMinimum(int)`

### method:setMaximum(int) [NONE]
- #### setMaximum
      public void setMaximum(int 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. Parameters: `n` - the new maximum See Also: `getMaximum()`, `addChangeListener(javax.swing.event.ChangeListener)`, `BoundedRangeModel.setMaximum(int)`

### method:setIndeterminate(boolean) [NONE]
- #### setIndeterminate
      public void setIndeterminate(boolean newValue)
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. Parameters: `newValue` - `true` if the progress bar should change to indeterminate mode; `false` if it should revert to normal. Since: 1.4 See Also: `isIndeterminate()`, `BasicProgressBarUI`

### method:isIndeterminate() [NONE]
- #### isIndeterminate
      public boolean isIndeterminate()
Returns the value of the `indeterminate` property. Returns: the value of the `indeterminate` property Since: 1.4 See Also: `setIndeterminate(boolean)`

### method:paramString() [NONE]
- #### paramString
      protected String paramString()
Returns a string representation of this `JProgressBar`. This method is intended to be used only for debugging purposes. The content and format of the returned string may vary between implementations. The returned string may be empty but may not be `null`. Overrides: `paramString` in class `JComponent` Returns: a string representation of this `JProgressBar`

### method:getAccessibleContext() [NONE]
- #### getAccessibleContext
      public AccessibleContext getAccessibleContext()
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. Specified by: `getAccessibleContext` in interface `Accessible` Overrides: `getAccessibleContext` in class `Component` Returns: an `AccessibleJProgressBar` that serves as the `AccessibleContext` of this `JProgressBar`