-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.java
68 lines (64 loc) · 1.94 KB
/
Program.java
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
package percentage;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.net.ssl.SSLContext;
public class Program extends Frame implements ActionListener{
class we extends WindowAdapter{
@Override
public void windowClosing(WindowEvent e) {dispose();}
}
Indicator[] ind=new Indicator[2];
Panel hd=new Panel();
Panel ft=new Panel();
Button b[]=new Button[2];
Progress[] n=new Progress[2];
Simulated_work[] s=new Simulated_work[2];
public Program() throws G_informative {
super("Progress");setBounds(500,100,600,400);
ind[0]=new Square_indicator(200, 250, Color.gray);
ind[1]=new Circular_indicator(200, 200, Color.red);
Panel p1=new Panel();p1.add(ind[0]);
Panel p2=new Panel();p2.add(ind[1]);
hd.add(p1);
hd.add(p2);addWindowListener(new we());
for (int i = 0; i < b.length; i++) {
b[i]=new Button("Start");b[i].addActionListener(this);
s[i]=new Simulated_work(1000, 10, 5, 15);
n[i]=new Progress(ind[i]);
s[i].subscribe(n[i]);
ft.add(b[i]);
}
b[0].setActionCommand("1");
b[1].setActionCommand("2");
Panel hlPanel=new Panel(new GridLayout(1,2));;
//hlPanel.add(hd,BorderLayout.NORTH);
add(ft,BorderLayout.SOUTH);
add(hd,BorderLayout.NORTH);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent arg0) {
if(arg0.getActionCommand().equals("1")) {
s[0].w_continue();
b[0].setActionCommand("~1");
}
else if(arg0.getActionCommand().equals("2")) {
s[1].w_continue();
b[1].setActionCommand("~2");
}
else if(arg0.getActionCommand().equals("~1")) {
s[0].w_stop();
b[0].setActionCommand("1");
}
else if(arg0.getActionCommand().equals("~2")) {
s[0].w_stop();
b[0].setActionCommand("2");
}
}
public static void main(String[] args) throws G_informative {
Program p=new Program();
}
}