-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOverPanel.java
More file actions
46 lines (37 loc) · 1.47 KB
/
GameOverPanel.java
File metadata and controls
46 lines (37 loc) · 1.47 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
40
41
42
43
44
45
46
package Project;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GameOverPanel extends JPanel {
public GameOverPanel(MainApp mainApp) {
setLayout(new BorderLayout());
// "Game Over" message
JLabel gameOverLabel = new JLabel("Game Over", SwingConstants.CENTER);
gameOverLabel.setFont(new Font("Arial", Font.BOLD, 36));
add(gameOverLabel, BorderLayout.CENTER);
// Button panel at the bottom
JPanel buttonPanel = new JPanel();
// Home Screen button returns to the home screen
JButton homeButton = new JButton("Home Screen");
homeButton.setFont(new Font("Arial", Font.PLAIN, 20));
homeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainApp.showHome();
}
});
buttonPanel.add(homeButton);
// Exit button closes the app
JButton exitButton = new JButton("Exit");
exitButton.setFont(new Font("Arial", Font.PLAIN, 20));
exitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
buttonPanel.add(exitButton);
add(buttonPanel, BorderLayout.SOUTH);
}
}