Java Swing Tutorial - Java JProgressBar(int orient) Constructor








Syntax

JProgressBar(int orient) constructor from JProgressBar has the following syntax.

public JProgressBar(int orient)

Example

In the following code shows how to use JProgressBar.JProgressBar(int orient) constructor.

import java.awt.BorderLayout;
//from www  .  ja  v  a 2s.c  om
import javax.swing.JFrame;
import javax.swing.JProgressBar;

public class Main {
  public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("ProgressBars");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    JProgressBar dJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    dJProgressBar.setValue(100);
    dJProgressBar.setBorderPainted(false);
    dJProgressBar.setString("Ack");
    dJProgressBar.setStringPainted(true);

    frame.add(dJProgressBar, BorderLayout.WEST);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }

}