-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainGame.java
100 lines (61 loc) · 2.18 KB
/
mainGame.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.event.ActionListener;
public class mainGame extends JFrame implements ActionListener {
gamePanel game;
JLabel label;
String text = "Othello - 2010 ";
String t = "Visit www.centralconnector.com";
int response = 0;
public mainGame() {
super("Othello");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menubar = new JMenuBar();
setJMenuBar(menubar);
JMenu file = new JMenu("File");
menubar.add(file);
JMenuItem ngame = new JMenuItem("New Game");
file.add(ngame);
ngame.addActionListener(this);
JMenuItem exit = new JMenuItem("Exit");
file.add(exit);
exit.addActionListener(this);
JMenu help = new JMenu("Help");
menubar.add(help);
JMenuItem contents = new JMenuItem("Contents");
help.add(contents);
contents.addActionListener(this);
JMenuItem about = new JMenuItem("About");
help.add(about);
about.addActionListener(this);
setSize(500, 500);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("New Game")) {
String options[] = new String[3];
options[0] = "Easy";
options[1] = "Medium";
options[2] = "Difficult";
// response=JOptionPane.showOptionDialog(null,"New game","Choose Difficulty:",0,JOptionPane.QUESTION_MESSAGE, null, options,options[1]);
game = new gamePanel(70, 70, 40, 40, response);
add(game);
}
if (e.getActionCommand().equals("Exit")) {
System.exit(0);
}
if (e.getActionCommand().equals("Contents")) {
JOptionPane.showMessageDialog(this, t);
setLayout(new FlowLayout());
}
if (e.getActionCommand().equals("About")) {
JOptionPane.showMessageDialog(this, text);
setLayout(new FlowLayout());
}
}
public static void main(String args[]) throws IOException {
mainGame m = new mainGame();
}
}