home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / ProgressMonitor.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.1 KB  |  164 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4.  
  5. public class ProgressMonitor {
  6.    private ProgressMonitor root;
  7.    private JDialog dialog;
  8.    private JOptionPane pane;
  9.    private JProgressBar myBar;
  10.    private JLabel noteLabel;
  11.    private Component parentComponent;
  12.    private String note;
  13.    private Object[] cancelOption;
  14.    private Object message;
  15.    // $FF: renamed from: T0 long
  16.    private long field_0;
  17.    private int millisToDecideToPopup;
  18.    private int millisToPopup;
  19.    private int min;
  20.    private int max;
  21.    // $FF: renamed from: v int
  22.    private int field_1;
  23.    private int lastDisp;
  24.    private int reportDelta;
  25.  
  26.    public ProgressMonitor(Component var1, Object var2, String var3, int var4, int var5) {
  27.       this(var1, var2, var3, var4, var5, (ProgressMonitor)null);
  28.    }
  29.  
  30.    private ProgressMonitor(Component var1, Object var2, String var3, int var4, int var5, ProgressMonitor var6) {
  31.       this.cancelOption = null;
  32.       this.millisToDecideToPopup = 500;
  33.       this.millisToPopup = 2000;
  34.       this.min = var4;
  35.       this.max = var5;
  36.       this.parentComponent = var1;
  37.       this.cancelOption = new Object[1];
  38.       this.cancelOption[0] = UIManager.getString("OptionPane.cancelButtonText");
  39.       this.reportDelta = (var5 - var4) / 100;
  40.       if (this.reportDelta < 1) {
  41.          this.reportDelta = 1;
  42.       }
  43.  
  44.       this.field_1 = var4;
  45.       this.message = var2;
  46.       this.note = var3;
  47.       if (var6 != null) {
  48.          this.root = var6.root != null ? var6.root : var6;
  49.          this.field_0 = this.root.field_0;
  50.          this.dialog = this.root.dialog;
  51.       } else {
  52.          this.field_0 = System.currentTimeMillis();
  53.       }
  54.  
  55.    }
  56.  
  57.    public void setProgress(int var1) {
  58.       this.field_1 = var1;
  59.       if (var1 >= this.max) {
  60.          this.close();
  61.       } else if (var1 >= this.lastDisp + this.reportDelta) {
  62.          this.lastDisp = var1;
  63.          if (this.myBar != null) {
  64.             this.myBar.setValue(var1);
  65.          } else {
  66.             long var2 = System.currentTimeMillis();
  67.             long var4 = (long)((int)(var2 - this.field_0));
  68.             if (var4 >= (long)this.millisToDecideToPopup) {
  69.                int var6;
  70.                if (var1 > this.min) {
  71.                   var6 = (int)(var4 * (long)(this.max - this.min) / (long)(var1 - this.min));
  72.                } else {
  73.                   var6 = this.millisToPopup;
  74.                }
  75.  
  76.                if (var6 >= this.millisToPopup) {
  77.                   this.myBar = new JProgressBar();
  78.                   this.myBar.setMinimum(this.min);
  79.                   this.myBar.setMaximum(this.max);
  80.                   this.myBar.setValue(var1);
  81.                   if (this.note != null) {
  82.                      this.noteLabel = new JLabel(this.note);
  83.                   }
  84.  
  85.                   this.pane = new ProgressOptionPane(this, new Object[]{this.message, this.noteLabel, this.myBar});
  86.                   this.dialog = this.pane.createDialog(this.parentComponent, "Progress...");
  87.                   this.dialog.show();
  88.                }
  89.             }
  90.          }
  91.       }
  92.  
  93.    }
  94.  
  95.    public void close() {
  96.       if (this.dialog != null) {
  97.          this.dialog.setVisible(false);
  98.          this.dialog.dispose();
  99.          this.dialog = null;
  100.          this.pane = null;
  101.          this.myBar = null;
  102.       }
  103.  
  104.    }
  105.  
  106.    public int getMinimum() {
  107.       return this.min;
  108.    }
  109.  
  110.    public void setMinimum(int var1) {
  111.       this.min = var1;
  112.    }
  113.  
  114.    public int getMaximum() {
  115.       return this.max;
  116.    }
  117.  
  118.    public void setMaximum(int var1) {
  119.       this.max = var1;
  120.    }
  121.  
  122.    public boolean isCanceled() {
  123.       if (this.pane == null) {
  124.          return false;
  125.       } else {
  126.          Object var1 = this.pane.getValue();
  127.          return var1 != null && this.cancelOption.length == 1 && var1.equals(this.cancelOption[0]);
  128.       }
  129.    }
  130.  
  131.    public void setMillisToDecideToPopup(int var1) {
  132.       this.millisToDecideToPopup = var1;
  133.    }
  134.  
  135.    public int getMillisToDecideToPopup() {
  136.       return this.millisToDecideToPopup;
  137.    }
  138.  
  139.    public void setMillisToPopup(int var1) {
  140.       this.millisToPopup = var1;
  141.    }
  142.  
  143.    public int getMillisToPopup() {
  144.       return this.millisToPopup;
  145.    }
  146.  
  147.    public void setNote(String var1) {
  148.       this.note = var1;
  149.       if (this.noteLabel != null) {
  150.          this.noteLabel.setText(var1);
  151.       }
  152.  
  153.    }
  154.  
  155.    public String getNote() {
  156.       return this.note;
  157.    }
  158.  
  159.    // $FF: synthetic method
  160.    static Object[] access$000(ProgressMonitor var0) {
  161.       return var0.cancelOption;
  162.    }
  163. }
  164.