-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOptionsMenu.java
126 lines (97 loc) · 2.48 KB
/
OptionsMenu.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class OptionsMenu extends JMenuBar
{
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenu helpMenu;
private JMenuItem newItem;
private JMenuItem restartItem; //
private JMenuItem exitItem;
private JCheckBoxMenuItem checkItem; //
private JMenuItem showAnsItem; //
private JMenuItem helpItem;
private int lvl;
// Make NonoGUI get the JMenuBar
public OptionsMenu(int level)
{
lvl = level;
menuBar = new JMenuBar();
buildFileMenu();
menuBar.add(fileMenu);
buildHelpMenu();
menuBar.add(helpMenu);
}
public void buildFileMenu()
{
fileMenu = new JMenu("File", true);
fileMenu.setMnemonic(KeyEvent.VK_F);
newItem = new JMenuItem("New Game", KeyEvent.VK_N);
//newItem.setMnemonic(KeyEvent.VK_N);
newItem.addActionListener(new NewListener());
restartItem = new JMenuItem("Restart", KeyEvent.VK_R);
//restartItem.setMnemonic(KeyEvent.VK_R);
exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
//exitItem.setMnemonic(KeyEvent.VK_X);
exitItem.addActionListener(new ExitListener());
fileMenu.add(newItem);
fileMenu.add(restartItem);
fileMenu.addSeparator();
fileMenu.add(exitItem);
}
public void buildHelpMenu()
{
helpMenu = new JMenu("Help", true);
helpMenu.setMnemonic(KeyEvent.VK_H);
checkItem = new JCheckBoxMenuItem("Check for Mistakes", false);
checkItem.setMnemonic(KeyEvent.VK_C);
showAnsItem = new JMenuItem("Show Answer", KeyEvent.VK_S);
//showAnsItem.setMnemonic(KeyEvent.VK_S);
helpItem = new JMenuItem("Instructions", KeyEvent.VK_I);
//helpItem.setMnemonic(KeyEvent.VK_I);
helpItem.addActionListener(new HelpListener());
helpMenu.add(checkItem);
helpMenu.add(showAnsItem);
helpMenu.add(helpItem);
}
public JMenuBar getOptionsMenuBar()
{
return menuBar;
}
public JMenuItem getRestartItem()
{
return restartItem;
}
public JCheckBoxMenuItem getCheckItem()
{
return checkItem;
}
public JMenuItem getShowAnsItem()
{
return showAnsItem;
}
private class HelpListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
new Help();
}
}
private class NewListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
new LvlGUI();
}
}
private class ExitListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Thanks for playing! Come again! ^_^");
System.exit(0);
}
}
}