29 import javax.swing.*; |
29 import javax.swing.*; |
30 |
30 |
31 /** |
31 /** |
32 * Main menu bar. |
32 * Main menu bar. |
33 */ |
33 */ |
34 public class MainMenu { |
34 public class MainMenu extends JMenuBar { |
35 |
35 |
36 private final ActionHandler handler; |
36 private final ActionHandler handler; |
37 private final JMenuBar menuBar; |
37 |
38 |
|
39 public MainMenu(ActionHandler h) { |
38 public MainMenu(ActionHandler h) { |
40 handler = h; |
39 handler = h; |
41 menuBar = new JMenuBar(); |
40 add(createMenu("Datei", 'd', |
42 menuBar.add(createMenu("Datei", 'd', |
|
43 createMenuItem("Neu", 'n', "control N", ActionHandler.NEW), |
41 createMenuItem("Neu", 'n', "control N", ActionHandler.NEW), |
44 createMenuItem("Öffnen", 'f', "control O", ActionHandler.OPEN), |
42 createMenuItem("Öffnen", 'f', "control O", ActionHandler.OPEN), |
45 createMenuItem("Speichern", 's', "control S", ActionHandler.SAVE), |
43 createMenuItem("Speichern", 's', "control S", ActionHandler.SAVE), |
46 createMenuItem("Speichern als...", 'a', ActionHandler.SAVE_AS), |
44 createMenuItem("Speichern als...", 'a', ActionHandler.SAVE_AS), |
47 createSeparator(), |
45 createSeparator(), |
48 createMenuItem("Prüfen", 'p', "control P", ActionHandler.CHECK), |
46 createMenuItem("Prüfen", 'p', "control P", ActionHandler.CHECK), |
49 createMenuItem("Lösen", 'l', "control L", ActionHandler.SOLVE), |
47 createMenuItem("Lösen", 'l', "control L", ActionHandler.SOLVE), |
50 createSeparator(), |
48 createSeparator(), |
51 createMenuItem("Beenden", 'e', ActionHandler.QUIT) |
49 createMenuItem("Beenden", 'e', ActionHandler.QUIT) |
52 )); |
50 )); |
53 menuBar.add(createMenu("Info", 'i', |
51 add(createMenu("Info", 'i', |
54 createMenuItem("Über...", 'b', "F1", ActionHandler.ABOUT) |
52 createMenuItem("Über...", 'b', "F1", ActionHandler.ABOUT) |
55 )); |
53 )); |
56 } |
54 } |
57 |
55 |
58 private JMenuItem createSeparator() { |
56 private JMenuItem createSeparator() { |