X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FMainWindowsView.java;h=729a9ad20382654cc21213f283a6f455e7d9f0c8;hb=f1e9d6d2fcc7253b117278c4439b656a1e532e68;hp=065c90d8050f0deb9203ce7733bb26b49b64c029;hpb=089fcbfccd75b77daf843b22e128beeee1d1dc07;p=Persons_Comparator.git diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index 065c90d..729a9ad 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -1,8 +1,11 @@ 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 { + MainWindowsView(String title) { //Create and set up the window. setTitle(title); @@ -10,6 +13,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. @@ -40,5 +57,4 @@ public class MainWindowsView extends JFrame { //this.pack(); this.setVisible(true); } - -} +} \ No newline at end of file