Is it possible to start JProgressBar from inbetween.I know this is wierd but I need to show the update between 20-80% and the progress bar should be invisible between 0-20% and 80-100% and the number 20 and 80 are run time variables.
Asked
Active
Viewed 320 times
1 Answers
2
The value displayed is dictated by the underlying data model (BoundedRangeModel
). You could subclass the DefaultBoundedRangeModel
(or create on from scratch by implementing BoundedRangeModel
) so that the getExtent()
always returns between 20-80%.
The new model can be supplied to JProgressBar
via its constructor or setModel
method.

Kris
- 14,426
- 7
- 55
- 65
-
I tried to access getModel and set the values as 20 and 80 but it creates new problem.Actually it reduces its range to 20-80 and there by to denote 45% complettion it will denote it as 42% which is numerical.What I need is GUI based.To be more specific I am embedding this progress bar inside a JTable cell and paint it in between(20%-80%) the table cell will have any value between 20-80 and I need to paint till that part starting from 20.I am not sure whether its clear but I can explain if you need. – Harish Aug 27 '10 at 10:26
-
@Harish, I've edited my answer. It is a more complicated solution but will give you fine grained control over what the JProgressBar is displaying. – Kris Aug 27 '10 at 10:56