Search code examples
javaswingjprogressbar

JProgressBar query


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.


Solution

  • 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.