home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / util / ProgressDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  3.7 KB  |  103 lines

  1. package com.extensibility.util;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Frame;
  8. import java.awt.GridBagConstraints;
  9. import java.awt.GridBagLayout;
  10. import java.awt.Insets;
  11. import java.awt.Window;
  12. import javax.swing.Icon;
  13. import javax.swing.JButton;
  14. import javax.swing.JFrame;
  15. import javax.swing.JLabel;
  16. import javax.swing.JPanel;
  17. import javax.swing.JProgressBar;
  18. import javax.swing.Timer;
  19.  
  20. public class ProgressDialog extends JFrame {
  21.    static final Color BG_COLOR = new Color(16777170);
  22.    static final int ONE_SECOND = 1000;
  23.    static final int APPEARANCE_DELAY = 750;
  24.    static final int SLEEP_TIME = 250;
  25.    JLabel iconLbl;
  26.    int max;
  27.    JLabel operation;
  28.    JLabel nowDoing;
  29.    JButton stopBtn;
  30.    JProgressBar progress;
  31.    ProgressTask progressTask;
  32.    Timer timer;
  33.  
  34.    public ProgressDialog(ProgressTask var1, Icon var2, String var3, int var4, String var5) {
  35.       ((Component)this).setVisible(false);
  36.       this.max = var4;
  37.       JPanel var6 = new JPanel();
  38.       ((JFrame)this).getContentPane().setLayout(new BorderLayout());
  39.       ((JFrame)this).getContentPane().add(var6, "Center");
  40.       ((Frame)this).setTitle(var3);
  41.       this.progressTask = var1;
  42.       ((Container)var6).setLayout(new GridBagLayout());
  43.       GridBagConstraints var7 = new GridBagConstraints();
  44.       var7.gridx = 0;
  45.       var7.gridy = 0;
  46.       var7.insets = new Insets(16, 16, 16, 16);
  47.       this.iconLbl = new JLabel(var2);
  48.       ((Container)var6).add(this.iconLbl, var7);
  49.       this.operation = new JLabel(var3);
  50.       this.operation.setFont(((Component)this).getFont());
  51.       var7.insets = new Insets(8, 8, 4, 8);
  52.       var7.gridx = 1;
  53.       ((Container)var6).add(this.operation, var7);
  54.       var7.fill = 2;
  55.       var7.weightx = (double)1.0F;
  56.       this.progress = new JProgressBar();
  57.       this.progress.setMaximum(var4);
  58.       var7.gridx = 0;
  59.       var7.gridy = 1;
  60.       var7.gridwidth = 2;
  61.       var7.ipady = 8;
  62.       ((Container)var6).add(this.progress, var7);
  63.       this.nowDoing = new JLabel();
  64.       var7.gridy = 2;
  65.       var7.insets = new Insets(0, 8, 8, 8);
  66.       var7.ipadx = 50;
  67.       ((Container)var6).add(this.nowDoing, var7);
  68.       ((Window)this).pack();
  69.       this.timer = new Timer(1000, new TimerListener(this));
  70.       this.timer.setInitialDelay(750);
  71.       this.timer.start();
  72.       ((Window)this).addWindowListener(new 1(this));
  73.    }
  74.  
  75.    public ProgressDialog(ProgressTask var1, Icon var2, String var3, int var4) {
  76.       this(var1, var2, var3, var4, "Stop");
  77.    }
  78.  
  79.    public ProgressDialog(ProgressTask var1, Icon var2, String var3, String var4) {
  80.       this(var1, var2, var3, 100, var4);
  81.    }
  82.  
  83.    public ProgressDialog(ProgressTask var1, String var2) {
  84.       this(var1, (Icon)null, var2, 100, "Stop");
  85.    }
  86.  
  87.    void updateProgress() {
  88.       int var1 = this.progressTask.getPctComplete();
  89.       this.progress.setValue(var1);
  90.       if (this.progressTask.done()) {
  91.          ((Component)this).setVisible(false);
  92.          this.timer.stop();
  93.       } else {
  94.          if (!((Component)this).isVisible()) {
  95.             ((Component)this).setVisible(true);
  96.          }
  97.  
  98.          this.nowDoing.setText(this.progressTask.getCurrentActivity());
  99.       }
  100.  
  101.    }
  102. }
  103.