-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultPage.java
More file actions
56 lines (45 loc) · 1.31 KB
/
Copy pathResultPage.java
File metadata and controls
56 lines (45 loc) · 1.31 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
47
48
49
50
51
52
53
54
55
56
package january;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Action;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ResultPage extends JFrame implements ActionListener {
private JLabel resultWindow;
private JButton exitBtn;
private JButton playAgainBtn;
public ResultPage(int playerWon) {
Font font = new Font("Comic Sans MS", 2, 30);
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
resultWindow = new JLabel("player " + playerWon + " has won");
resultWindow.setFont(font);
playAgainBtn = new JButton("Play Again");
playAgainBtn.setFont(font);
playAgainBtn.addActionListener(this);
exitBtn = new JButton("Exit");
exitBtn.setFont(font);
exitBtn.addActionListener(this);
super.setTitle("Tic Tac Toe");
super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
super.setExtendedState(MAXIMIZED_BOTH);
super.setVisible(true);
super.setSize(800, 500);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getSource() == exitBtn) {
dispose();
}
if (e.getSource() == playAgainBtn) {
dispose();
new Menu();
}
}
}