-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoringPanel.java
More file actions
40 lines (30 loc) · 851 Bytes
/
ScoringPanel.java
File metadata and controls
40 lines (30 loc) · 851 Bytes
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
import javax.swing.*;
import java.awt.*;
public class ScoringPanel extends JPanel{
private JLabel scoreL;
private JTextField scoreTF;
private int score;
public ScoringPanel(){
GridLayout gridLayout = new GridLayout(1, 2);
setLayout(gridLayout);
score = 0;
scoreL = new JLabel ("Score: ");
// create text fields and set their colour, etc.
scoreTF = new JTextField (Integer.toString(score), 5);
scoreTF.setEditable(false);
scoreTF.setBackground(Color.WHITE);
add(scoreL);
add(scoreTF);
}
public void addPoints(int points){
score+= points;
scoreTF.setText(Integer.toString(score));
}
public void initialize(int init){
score= 0;
scoreTF.setText(Integer.toString(init));
}
public int getScore(){
return score;
}
}