The JProgressBar class is used to display the progress of the task. It inherits JComponent class.
Let's see the declaration for javax.swing.JProgressBar class.
| Constructor | Description |
|---|---|
| JProgressBar() | It is used to create a horizontal progress bar but no string text. |
| JProgressBar(int min, int max) | It is used to create a horizontal progress bar with the specified minimum and maximum value. |
| JProgressBar(int orient) | It is used to create a progress bar with the specified orientation, it can be either Vertical or Horizontal by using SwingConstants.VERTICAL and SwingConstants.HORIZONTAL constants. |
| JProgressBar(int orient, int min, int max) | It is used to create a progress bar with the specified orientation, minimum and maximum value. |
| Method | Description |
|---|---|
| void setStringPainted(boolean b) | It is used to determine whether string should be displayed. |
| void setString(String s) | It is used to set value to the progress string. |
| void setOrientation(int orientation) | It is used to set the orientation, it may be either vertical or horizontal by using SwingConstants.VERTICAL and SwingConstants.HORIZONTAL constants. |
| void setValue(int value) | It is used to set the current value on the progress bar. |
Output:

We request you to subscribe our newsletter for upcoming updates.