-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighScorePanel.java
More file actions
39 lines (33 loc) · 1.28 KB
/
Copy pathHighScorePanel.java
File metadata and controls
39 lines (33 loc) · 1.28 KB
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
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class HighScorePanel extends JPanel {
JTextArea textField;
final int PANEL_WIDTH = 700;
final int PANEL_HEIGHT = 700;
JLabel highScoreLabel = new JLabel("HIGH SCORES");
static String filePath = "/Users/ecetipici/IdeaProjects/spaceInvadersGame/scores.txt";
Image backgroundImage;
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);
}
HighScorePanel() {
this.setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
this.setLayout(null);
backgroundImage = new ImageIcon("images/spaceImage.png").getImage();
this.setFocusable(true);
highScoreLabel.setForeground(Color.white);
highScoreLabel.setFont(new Font("Arial", Font.ITALIC, 28));
highScoreLabel.setBounds(250, 100, 500, 40);
this.add(highScoreLabel);
textField = new JTextArea();
textField.setBounds(120, 150,490, 370);
textField.setBackground(Color.white);
textField.setLineWrap(true);
textField.setWrapStyleWord(true);
textField.setText(FileUtil.readUsernameAndScore(filePath));
this.add(textField);
}
}