FileDocCategorySizeDatePackage
ProgressBarExample.javaAPI DocExample1215Thu Oct 24 20:14:22 BST 2002None

ProgressBarExample

public class ProgressBarExample extends JPanel

Fields Summary
JProgressBar
pbar
static final int
MY_MINIMUM
static final int
MY_MAXIMUM
Constructors Summary
public ProgressBarExample()


    
     pbar = new JProgressBar();
     pbar.setMinimum(MY_MINIMUM);
     pbar.setMaximum(MY_MAXIMUM);
     add(pbar);
  
Methods Summary
public static voidmain(java.lang.String[] args)


     final ProgressBarExample it = new ProgressBarExample();

     JFrame frame = new JFrame("Progress Bar Example");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
     frame.setContentPane(it);
     frame.pack();
     frame.setVisible(true);

     for (int i = MY_MINIMUM; i <= MY_MAXIMUM; i++) {
       final int percent=i;
       try {
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
               it.updateBar(percent);
             }
         });
         java.lang.Thread.sleep(100);
       } catch (InterruptedException e) {;}
     } 
  
public voidupdateBar(int newValue)

    pbar.setValue(newValue);