Java Swing Tutorial - Java JProgressBar .setOrientation (int newOrientation)








Syntax

JProgressBar.setOrientation(int newOrientation) has the following syntax.

public void setOrientation(int newOrientation)

Example

In the following code shows how to use JProgressBar.setOrientation(int newOrientation) method.

import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
//from   w  w  w .  j  a va 2 s .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);

  }
}