KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > event > ProgressEvent


1 /*
2  * $Id: ProgressEvent.java,v 1.1.1.1 2004/06/16 01:43:39 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.event;
9
10 /**
11  * A MessageEvent that represents the cycle of a long running operation.
12  * Use the constructors to indicate the stage of the operation.
13  *
14  * @author Mark Davidson
15  */

16 public class ProgressEvent extends MessageEvent {
17
18     private int minimum;
19     private int maximum;
20     private int progress;
21
22     private boolean indeterminate = true;
23
24     /**
25      * Constructs an indeterminate progress event.
26      */

27     public ProgressEvent(Object JavaDoc source) {
28     super(source);
29     }
30
31     /**
32      * Constructs a progress event used to indicate an increment of progress.
33      *
34      * @param source the object which orignated the event
35      * @param progress the value between min and max which indicates
36      * the progression of the operation.
37      */

38     public ProgressEvent(Object JavaDoc source, int progress) {
39     super(source);
40     this.progress = progress;
41     setIndeterminate(false);
42     }
43
44     /**
45      * Constructs a ProgressEvent which indicates the beginning of a long operation.
46      * For a determinite progress operation, the minimum value should be less than
47      * the maximum value. For indterminate operations, set minimum equal to maximum.
48      *
49      * @param source the object which orignated the event
50      * @param min the minimum value of the progress operation
51      * @param max the maximum value of the progress operation
52      */

53     public ProgressEvent(Object JavaDoc source, int min, int max) {
54     super(source);
55     setMaximum(max);
56     setMinimum(min);
57     setIndeterminate(max == min);
58     }
59
60     private void setMaximum(int max) {
61     this.maximum = max;
62     }
63
64     public int getMaximum() {
65     return maximum;
66     }
67
68     private void setMinimum(int min) {
69     this.minimum = min;
70     }
71
72     public int getMinimum() {
73     return minimum;
74     }
75
76     private void setIndeterminate(boolean indeterminate) {
77     this.indeterminate = indeterminate;
78     }
79
80     public boolean isIndeterminate() {
81     return indeterminate;
82     }
83
84     public int getProgress() {
85     return progress;
86     }
87 }
88
Popular Tags