Getting and Setting the Values of a JProgressBar Component

// To create a progress bar, see Creating a JProgressBar Component // Get the current value int value = progress.getValue(); // Get the minimum value int min = progress.getMinimum(); // Get the maximum value int max = progress.getMaximum(); // Change the minimum value int newMin = 0; progress.setMinimum(newMin); // Change the maximum value int newMax = 256; progress.setMaximum(newMax); // Set the value; the new value will be forced into the bar's range int newValue = 33; progress.setValue(newValue);
It is also possible to set all the values at once by using the model:
progress.getModel().setRangeProperties(newValue, 0, newMin, newMax, false);

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.