Java Swing Tutorial - Java JProgressBar.getString()








Syntax

JProgressBar.getString() has the following syntax.

public String getString()

Example

In the following code shows how to use JProgressBar.getString() method.

import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
/*ww  w.j  a v  a 2s  . co m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);
    progress.setString("value");
    System.out.println(progress.getString());
  }
}