Add a menu to the main windows.
[Persons_Comparator.git] / src / MainWindowsView.java
index 065c90d8050f0deb9203ce7733bb26b49b64c029..bc7951152f608bfdd4f8633efc2a9b99120cc8f1 100644 (file)
@@ -1,5 +1,7 @@
 import javax.swing.*;
 import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.util.ArrayList;
 
 public class MainWindowsView extends JFrame {
@@ -10,6 +12,20 @@ public class MainWindowsView extends JFrame {
         setLocationRelativeTo(null);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
+        //Create menu
+        JMenuBar menuBar = new JMenuBar();
+        setJMenuBar(menuBar);
+        JMenu fileMenu = new JMenu("File");
+        menuBar.add(fileMenu);
+        JMenuItem exit = new JMenuItem("Exit");
+        exit.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                System.exit(0);
+            }
+        });
+        fileMenu.add(exit);
+
+        //Main pane
         JPanel panel = new PersonView();
 
         //Get all Swing/AWT primitive components in the views and add them to the panel.
@@ -41,4 +57,4 @@ public class MainWindowsView extends JFrame {
         this.setVisible(true);
     }
 
-}
+}
\ No newline at end of file