-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgressBar.java
More file actions
executable file
·100 lines (82 loc) · 2.53 KB
/
ProgressBar.java
File metadata and controls
executable file
·100 lines (82 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* ProgressBar.java
*
* Created on March 30, 2006, 10:30 AM
*/
/**
* @author Chen-Fu Liao
* Sr. Systems Engineer
* ITS Institute, ITS Laboratory
* Center For Transportation Studies
* University of Minnesota
* 200 Transportation and Safety Building
* 511 Washington Ave. SE
* Minneapolis, MN 55455
*/
import java.awt.*;
public class ProgressBar extends Frame
{
private int Count;
private int Max;
private static final int FrameBottom = 24;
public ProgressBar (String Title, int TotalItems)
{
super(Title);
Count = 0;
Max = TotalItems;
// Allowing this to be resized causes more trouble than it is worth
// and the goal is for this to load and launch quickly!
setResizable(false);
setLayout(null);
addNotify();
resize (insets().left + insets().right + 380,
insets().top + insets().bottom + FrameBottom);
}
public synchronized void show()
{
//move(50, 50);
setCenter();
super.show();
}
public void setCenter(){
Dimension screen = getToolkit().getDefaultToolkit().getScreenSize();
double top = 0.5*(screen.getWidth()-this.getWidth());
double left = 0.5*(screen.getHeight()-this.getHeight());
int x = new Double(top).intValue();
int y = new Double(left).intValue();
this.setLocation(x, y);
this.toFront();
}
// Update the count and then update the progress indicator. If we have
// updated the progress indicator once for each item, dispose of the
// progress indicator.System.out.println("url="+u.toString());
public void updateProgress ()
{
Count++;
if (Count == Max) {
//dispose();
Count=0 ;
}
Dimension myDimension = size();
int ProgressWidth = (myDimension.width * Count)/ Max;
// Fill the bar the appropriate percent full.
Graphics g = this.getGraphics();
g.setColor (new Color(0, 128, 0));
g.fillRect (0, 0, ProgressWidth, myDimension.height);
g.setColor (Color.white);
g.fillRect (ProgressWidth,0,myDimension.width-ProgressWidth, myDimension.height);
}
// Paint the progress indicator.
public void paint (Graphics g)
{
}
public boolean handleEvent(Event event)
{
if (event.id == Event.WINDOW_DESTROY)
{
dispose();
return true;
}
return super.handleEvent(event);
}
}