Java Swing How to - Create Indeterminate JProgressBar, Progress bar bounces back and forth from side to side








Question

We would like to know how to create Indeterminate JProgressBar, Progress bar bounces back and forth from side to side.

Answer

import java.awt.BorderLayout;
/*from  ww w.  j a v  a 2  s. c  o m*/
import javax.swing.JFrame;
import javax.swing.JProgressBar;

public class Main {

  public static void main(String args[]) {
    JFrame frame = new JFrame("Stepping Progress");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    aJProgressBar.setStringPainted(true);
    aJProgressBar.setIndeterminate(true);

    frame.add(aJProgressBar, BorderLayout.NORTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}