-
Notifications
You must be signed in to change notification settings - Fork 2
/
HMeterApp.java
69 lines (58 loc) · 1.91 KB
/
HMeterApp.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
69
package meter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class HMeterApp extends JFrame {
private HMeter meter1;
private HMeter meter2;
private HMeter meter3;
public HMeterApp() {
super("HMeter App");
setLocation(300,150);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new FlowLayout());
meter1 = new HMeter(50, "Meter 1");
meter1.setProgressColor(Color.GREEN);
meter1.setHollow(true);
meter1.setBoundaryColor(Color.GRAY);
meter1.setRadius(100);
add(meter1);
meter2 = new HMeter(75, "Meter 2");
meter2.setProgressColor(Color.BLUE);
meter2.setHollow(false);
meter2.setBoundaryColor(Color.RED);
meter2.setRadius(120);
add(meter2);
meter3 = new HMeter(25, "Meter 3");
meter3.setProgressColor(Color.YELLOW);
meter3.setHollow(true);
meter3.setBoundaryColor(Color.BLACK);
meter3.setRadius(90);
add(meter3);
JButton animateButton = new JButton("Animate");
animateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
meter1.setAnimate(true);
meter2.setAnimate(true);
meter3.setAnimate(true);
}
});
// @Override
// public void actionPerformed(ActionEvent e) {
// if (!meter1.isAnimate()) {
// meter1.setAnimate(true);
// meter2.setAnimate(true);
// meter3.setAnimate(true);
// }
// }
add(animateButton);
pack();
setVisible(true);
}
public static void main(String[] args) {
new HMeterApp();
}
}