FileDocCategorySizeDatePackage
ProgressBarExample.javaAPI DocExample1104Mon Nov 09 12:45:54 GMT 1998None

ProgressBarExample

public class ProgressBarExample extends JPanel

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


    
    super(true);
    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.addWindowListener(new BasicWindowMonitor());
    frame.setContentPane(it);
    frame.pack();
    frame.setVisible(true);

    for (int i = MY_MINIMUM; i <= MY_MAXIMUM; i++) {
      final int percent=i;
      try {
        SwingUtilities.invokeAndWait(
          new Runnable() {
            public void run() {
              it.updateBar(percent);
            }
        });

        java.lang.Thread.sleep(100);

       } catch (Exception e) {;}
    }
  
public voidupdateBar(int newValue)

    pbar.setValue(newValue);