-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfoPanel.java
42 lines (30 loc) · 1005 Bytes
/
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
package uet.oop.bomberman.gui;
import uet.oop.bomberman.Game;
import javax.swing.*;
import java.awt.*;
/**
* Swing Panel hiển thị thông tin thời gian, điểm mà người chơi đạt được
*/
public class InfoPanel extends JPanel {
private JLabel timeLabel;
private JLabel pointsLabel;
public InfoPanel(Game game) {
setLayout(new GridLayout());
timeLabel = new JLabel("Time: " + game.getBoard().getTime());
timeLabel.setForeground(Color.white);
timeLabel.setHorizontalAlignment(JLabel.CENTER);
pointsLabel = new JLabel("Points: " + game.getBoard().getPoints());
pointsLabel.setForeground(Color.white);
pointsLabel.setHorizontalAlignment(JLabel.CENTER);
add(timeLabel);
add(pointsLabel);
setBackground(Color.black);
setPreferredSize(new Dimension(0, 40));
}
public void setTime(int t) {
timeLabel.setText("Time: " + t);
}
public void setPoints(int t) {
pointsLabel.setText("Score: " + t);
}
}