-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameFrame.java
62 lines (46 loc) · 1.32 KB
/
GameFrame.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
//GameFrame.java
//For setting up the frame with all components.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GameFrame extends JFrame{
//constants
final static int FWIDTH = 1000;
final static int FHEIGHT = 900;
static GamePanel currentPanel = new GamePanel ();
//frame constructor
public GameFrame(){
JFrame frame = new JFrame("Go For it: Connect 4");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(FWIDTH, FHEIGHT);
Container content = frame.getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
content.add(new JLabel("Connect 4"));
//add the Components into the JFrame
frame.add(currentPanel);
frame.add(new ControlPanel());
//launch the frame
frame.setVisible(true);
}
//private listener class
private class GameListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
currentPanel.compTurn();
currentPanel.repaint();
}
}
//methods that the buttons call:
public static void moveNext(){
currentPanel.compTurn();
currentPanel.repaint();
}
public static void reset(){
currentPanel.reset();
currentPanel.repaint();
}
public static void undo(){
currentPanel.undo();
currentPanel.repaint();
}
}