Creating a JProgressBar Component with an Unknown Maximum

A progress bar with an unknown maximum typically displays an animation until the task is complete.

Note: The percentage display should not be enabled when the maximum is not known (Displaying the Percentage Done on a JProgressBar Component).

// Create a horizontal progress bar int min = 0; int max = 100; JProgressBar progress = new JProgressBar(min, max); // Play animation progress.setIndeterminate(true);
When information on the task's progress is available, the progress bar can be made determinate:
int value = 33; progress.setValue(value); progress.setIndeterminate(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.