-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPointsPanel.java
65 lines (55 loc) · 1.92 KB
/
PointsPanel.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
/* PointsPanel.java
*
* Written by: Jesslyn Tannady
* CS 230 Final Project: Pusheen Donut Dash
* Partners: Jamie Yip and Brenda Ji
* Last Modified: December 16, 2015
*
* Purpose: Represents the primary display panel for the Points program.
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PointsPanel extends JPanel
{
// Instance Variables
private int points;
private JButton push;
private JLabel textLabel, pointsLabel;
private Pusheen user;
/* Constructor: Creates the PointsPanel where the points collected will be
* displayed to the user. This panel must know about the same Pusheen object
* that the other Panels know about so that they are all working according to
* the same Pusheen
*
* @param pusheenUser The Pusheen that all the panels must know about
*/
public PointsPanel (Pusheen pusheenUser) {
user = pusheenUser; // Set user to the given Pusheen
points = 0; // Initialize starting points to 0
// Initializing the text and points label for PointsPanel
textLabel = new JLabel ("Points:");
pointsLabel = new JLabel (String.valueOf(points));
textLabel.setFont(new Font("Comic Sans", Font.BOLD, 25));
pointsLabel.setFont(new Font("Comic Sans", Font.PLAIN, 25));
// Add these components to the layout
setLayout(new BorderLayout());
add(textLabel, BorderLayout.NORTH);
add(pointsLabel, BorderLayout.CENTER);
// Set background and foreground colors
setBackground(new Color(250, 241, 227));
textLabel.setForeground(new Color(61, 34, 8));
pointsLabel.setForeground(new Color(61, 34, 8));
}
/**
* setPointsLabel()
* Allows other panels to set the Label in this PointsPanel
*
* @param p The number of points that Pusheen has collected
* @return Nothing
*/
public void setPointsLabel(int p){
points = p;
pointsLabel.setText(String.valueOf(points));
}
}