-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfoPanel.java
93 lines (57 loc) · 1.35 KB
/
InfoPanel.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.awt.Color;
import javax.swing.*;
import java.awt.*;
public class InfoPanel extends JPanel {
private int hits;
private int misses;
private int points;
private JLabel hitsL;
private JLabel missesL;
private JLabel pointsL;
private JTextField hitsTF;
private JTextField missesTF;
private JTextField pointsTF;
public InfoPanel () {
setBackground(Color.PINK);
hitsL = new JLabel ("# Goals");
missesL = new JLabel ("# Misses ");
pointsL = new JLabel ("Points");
hitsTF = new JTextField ();
missesTF = new JTextField ();
pointsTF = new JTextField ();
hitsTF.setEditable(false);
missesTF.setEditable(false);
pointsTF.setEditable(false);
GridLayout gridLayout;
gridLayout = new GridLayout(2, 4);
setLayout(gridLayout);
add (hitsL);
add (missesL);
add (pointsL);
add (hitsTF);
add (missesTF);
add (pointsTF);
resetInfo();
}
public void resetInfo () {
hits = misses = points = 0;
}
public void incrementHits () {
hits++;
}
public void incrementMisses () {
misses++;
}
public void incrementPoints (int numPoints) {
points+= numPoints;
}
public void decreasePoints(int points){
if((this.points - points)>-1){
this.points-= points;}
}
public void displayInfo () {
hitsTF.setText (hits+"");
missesTF.setText (misses+"");
pointsTF.setText (points+"");
}
}