-
Notifications
You must be signed in to change notification settings - Fork 0
/
menubar.java
89 lines (73 loc) · 2.3 KB
/
menubar.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
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class menubar extends JMenuBar{
public menubar(){
super();
JMenu gameMenu = new JMenu("Game");
JMenu helpMenu = new JMenu("Help");
gameMenu.setMnemonic('G');
JMenuItem resetItem = new JMenuItem("Reset");
JMenuItem topTenItem = new JMenuItem("Top Ten");
JMenuItem resetTopTen = new JMenuItem("Reset Top Ten");
JMenuItem exitItem = new JMenuItem("Exit");
JMenuItem aboutItem = new JMenuItem("About...");
JMenuItem helpItem = new JMenuItem("Help");
resetItem.setMnemonic('R');
topTenItem.setMnemonic('T');
exitItem.setMnemonic('E');
helpItem.setMnemonic('H');
aboutItem.setMnemonic('A');
gameMenu.add(resetItem);
gameMenu.add(topTenItem);
gameMenu.add(resetTopTen);
gameMenu.add(exitItem);
helpMenu.add(helpItem);
helpMenu.add(aboutItem);
resetItem.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent event){
myBoard.resetClick();
}
});
resetTopTen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
score.resetScores();
}
});
topTenItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
score.showTopTen();
}
});
exitItem.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent event){
System.exit(0);
}
});
aboutItem.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event){
JOptionPane.showMessageDialog(null,
"This minesweeper program was made by\nAdrian and Upesh for CS342.\n",
"About", JOptionPane.PLAIN_MESSAGE);
//System.out.println("ARGGH!!");
}
});
helpItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null,
"To play the game, try to find all the places that do not have mines.\n" +
"Right click on the buttons to indiciate there is a mine in that space.\n" +
"Click on a mine and you lose. Clear the board, with no mine hits and you win.\n",
"Help", JOptionPane.PLAIN_MESSAGE);
}
});
add(gameMenu);
add(helpMenu);
}
public void openTopTen(){
}
}