the MainMenu IS a JMenuBar

Mon, 27 Jul 2020 13:12:40 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 27 Jul 2020 13:12:40 +0200
changeset 18
530f60fa3dc9
parent 17
aad33a4db18d
child 19
627e1c99bcf1

the MainMenu IS a JMenuBar

src/main/java/de/uapcore/sudoku/MainMenu.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/sudoku/Sudoku.java file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/sudoku/MainMenu.java	Mon Jul 27 12:52:34 2020 +0200
+++ b/src/main/java/de/uapcore/sudoku/MainMenu.java	Mon Jul 27 13:12:40 2020 +0200
@@ -31,15 +31,13 @@
 /**
  * Main menu bar.
  */
-public class MainMenu {
+public class MainMenu extends JMenuBar {
     
     private final ActionHandler handler;
-    private final JMenuBar menuBar;
-    
+
     public MainMenu(ActionHandler h) {
         handler = h;
-        menuBar = new JMenuBar();
-        menuBar.add(createMenu("Datei", 'd',
+        add(createMenu("Datei", 'd',
             createMenuItem("Neu", 'n', "control N", ActionHandler.NEW),
             createMenuItem("Öffnen", 'f', "control O", ActionHandler.OPEN),
             createMenuItem("Speichern", 's', "control S", ActionHandler.SAVE),
@@ -50,7 +48,7 @@
             createSeparator(),
             createMenuItem("Beenden", 'e', ActionHandler.QUIT)
         ));
-        menuBar.add(createMenu("Info", 'i',
+        add(createMenu("Info", 'i',
             createMenuItem("Über...", 'b', "F1", ActionHandler.ABOUT)
         ));
     }
@@ -90,8 +88,5 @@
         
         return item;
     }
-    
-    public JMenuBar getMenuBar() {
-        return menuBar;
-    }
+
 }
--- a/src/main/java/de/uapcore/sudoku/Sudoku.java	Mon Jul 27 12:52:34 2020 +0200
+++ b/src/main/java/de/uapcore/sudoku/Sudoku.java	Mon Jul 27 13:12:40 2020 +0200
@@ -42,7 +42,7 @@
         
         Field f = new Field();
         ActionHandler h = new ActionHandler(f);
-        setJMenuBar(new MainMenu(h).getMenuBar());
+        setJMenuBar(new MainMenu(h));
         
         Container content = getContentPane();
         

mercurial