Getting and Setting the Values of a JProgressBar Component : JProgressBar « Swing « Java Tutorial






import javax.swing.JProgressBar;

public class Main {
  public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    // 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);

  }
}








14.32.JProgressBar
14.32.1.JProgressBarJProgressBar
14.32.2.Creating a JProgressBar Component with an Unknown Maximum
14.32.3.A progress bar is used for lengthy tasks.
14.32.4.Labeling a JProgressBarLabeling a JProgressBar
14.32.5.Virtical JProgressBarVirtical JProgressBar
14.32.6.Creating a modal progress dialog
14.32.7.Set all the values at once by using the model
14.32.8.Using an Indeterminate JProgressBarUsing an Indeterminate JProgressBar
14.32.9.Displaying the Percentage Done on a JProgressBar Component
14.32.10.Getting and Setting the Values of a JProgressBar Component
14.32.11.Listening for Value Changes in a JProgressBar Component
14.32.12.Handling JProgressBar Events: notification of data model changes through a ChangeListenerHandling JProgressBar Events: notification of data model changes through a ChangeListener
14.32.13.ProgressBar and Task
14.32.14.SwingWorker and ProgressBar
14.32.15.Customizing JProgressBar Look and Feel